# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (95 sloc) 4.84 KB
 Estimation with decimals
_.map( randRange(1000, 16000, randRange(3, 7)), function( n ) { var x = n / 1000; var precision = randRange(1, 2); return [roundTo(precision, x), precision]; }) sum(\$.map(VALUES, function(pair) { return round(pair[0]); })) randFromArray([ ["jogging", "ran", new Plural(function(n) { return i18n.ngettext("mile", "miles", n); })], ["riding a bicycle", "traveled", new Plural(function(n) { return i18n.ngettext("mile", "miles", n); })], ["collecting mushrooms", "collected", new Plural(function(n) { return i18n.ngettext("pound", "pounds", n); })], ["painting a roof", "painted", new Plural(function(n) { return i18n.ngettext("square foot", "square feet", n); })], ["harvesting grain", "harvested", new Plural(function(n) { return i18n.ngettext("tonne", "tonnes", n); })] ]) 0 (function() { var sum = 0; \$.each(VALUES, function(i, pair) { sum += roundTo(pair[1], pair[0]); }); return roundTo(2, sum); })()

person(1) has been TYPES[0] every day for the last VALUES.length days. The table below shows the amount he TYPES[1] in plural_form(TYPES[2]) each day. The table below shows the amount she TYPES[1] in plural_form(TYPES[2]) each day.

Estimate how much he TYPES[1] in total by first rounding each amount to the nearest whole number and then summing all the rounded amounts.

Estimate how much she TYPES[1] in total by first rounding each amount to the nearest whole number and then summing all the rounded amounts.

Note that if you sum the exact amounts (localeToFixed(SUM, 2)) and then round, you'll get round(SUM). For fun, pay attention to how this number compares with your estimate.

Day
" "
Amount
(in plural_form(TYPES[2]))
i+1 localeToFixed(pair[0], pair[1])