# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
86 lines (81 sloc) 3.69 KB
 Number line 1
randRange(1, 4) 0 10 * SCALE randRangeNonZero(3, 10) * SCALE

Where is NUMBER on the number line?

var scale = 40 / SCALE; init({ range: [[LOWER_BOUND - (30 / scale), UPPER_BOUND + (30 / scale)], [-1, 1]], scale: [40 / SCALE, 40] }); line([LOWER_BOUND - (25 / scale), 0], [UPPER_BOUND + (25 / scale), 0], { arrows: "->" }); line([UPPER_BOUND + (25 / scale), 0], [LOWER_BOUND - (25 / scale), 0], { arrows: "->" }); for (var x = LOWER_BOUND; x <= UPPER_BOUND; x += SCALE) { line([x, -0.2], [x, 0.2 ]); } style({ stroke: "#6495ED", strokeWidth: 3.5 }); line( [ 0, -0.2], [0, 0.2]); label( [ 0, -0.53 ], "0", "center"); label( [ SCALE, -0.53 ], SCALE, "center"); addMouseLayer(); var snap = SCALE / 4; if (SCALE === 3) { snap = SCALE / 3; } graph.movablePoint = addMovablePoint({ constraints: { constrainY: true }, snapX: snap }); graph.movablePoint.onMove = function( x, y ) { return [ min( max( LOWER_BOUND, x ), UPPER_BOUND ), y ]; };
graph.movablePoint.coord[0]
if (guess === 0) { return ""; } return abs(NUMBER - guess) < 0.001;
graph.movablePoint.setCoord([guess, 0]);

We know each tick mark is SCALE because 0 and SCALE are labeled.

Label the rest of the number line.

for (var x = LOWER_BOUND; x <= UPPER_BOUND; x += SCALE) { label([x, -0.53], ("" + x).replace(/-/, "\\llap{-}"), "center"); }

The orange number shows where NUMBER is on the number line.

label([ NUMBER, -0.53], ("" + NUMBER).replace(/-/, "\\llap{-}"), "center", { color: ORANGE }); graph.movablePoint.moveTo(NUMBER, 0);
Something went wrong with that request. Please try again.