Sum

The sum of two numbers is what you get when you add them together. Write an expression for the sum of the two numbers a and b.

Difference

The difference between two numbers is what you get when you subtract the second from the first. Write an expression for the difference between the two numbers a and b.

Product

The product of two numbers is what you get when you multiply them. Write an expression for the product of the two numbers a and b.

Ratio

The ratio between two numbers is what you get when you divide the first by the second. Write an expression for the ratio of the two numbers a and b.

Remainder

The remainder of of dividing one number by another is the integer part left over after doing a division. Write an expression for the reminder after dividing a by b.

Average

The average of two numbers is their sum divided by two. Write an expression for the average of the two numbers a and b.

Average of three

The average of three numbers is their sum divided by three. Write an expression for the average of the numbers a, b, and c.

General average

The average of an arbitrary number of numbers is their total divided the number of numbers. Write expression for the average of a set of count numbers whose total is total.

Distance

The distance between two numbers (e.g. on the number line) is the absolute value of their difference. The Math.abs function returns the absolute value of its argument. Write an expression that computes the distance between two numbers a and b.

Manhattan distance

The “Manhattan distance” between two points in 2d space is the sum of the distance between the points along the x axis (crosstown) and the distance between the points along the y axis (uptown/downtown). Write an expression that computes the Manhattan distance between two points the first whose x,y coordinates are given by the numbers x1 and y1 and the second by the numbers x2 and y2.

2D distance

The normal way we measure the distance between points in 2d space is called Euclidian distance and is computed as the square root of the sum of the squares of the distance along the x and y axes. Write an expression that computes the Euclidian distance between two points the first whose x,y coordinates are given by the numbers x1 and y1 and the second by the numbers x2 and y2. You can use the function Math.sqrt to compute the square root of a number, e.g. Math.sqrt(4)2.