Objective: Practice writing expressions and storing the results in variables.
In this exercise, write expressions to solve the problems described
in the comments, and store the results in variables. You can (and
should) just edit the code in the window below. When you are done, copy
and paste the code into a new text file in vscode. Save the results as
expressions.js
, and submit this file as part of your
solution on Canvas.
Objective: Use variables to allow behavior of code to be changed easily.
In part 2, you’ll use atom to edit some provided code.
The code provided will draw a smiley face on the screen, and you can
use the variables x
and y
to change where the
smiley face is drawn. But the smiley face is always the same size. Add a
new variable, scale
, that allows you to change the size of
the smiley face to make the face either larger or smaller. For example,
if scale
had the value 2, then the code would draw the
smiley face twice as large (but still centered on x
and
y
). The multiplication operator in javascript is written
using an asterisk, so 10 * 4
would have the value
40
.
Test your code by changing variable values a few times to draw the smiley face at different locations at both small and large scales.
Submit all of your code files on Canvas.