The result for the divide sum was fairly long.  To shorten it save arithmetic.html as math.html and add this line just before the final alert line (assuming your variable name is divided):


Save and try.  Note that this works differently to strings.  Strings are objects of the type string.  Variables containing numbers are not objects of the Math type.  Instead you use the method (round) by naming the Math object itself and telling it what to use inside the brackets.  Don't worry if that didn't make sense as long as you can see how the line works.  It rounds whatever is in the variable and puts the updated answer into the variable for later use.

Decimal places

Weirdly JavaScript can only round to whole numbers not to a few decimal places.  However if you want two decimal places you can multiply by 100, round it then divide by 100.  Do the same for 1 decimal place (10), three decimal places (1000) and so on.  Try this instead of the existing rounding line (above):


Floor and ceil

These are used instead of round to always round down or round up.  Try them and you would get 3 and 4 as the two answers.