0
0
Javascriptprogramming~10 mins

Why variables are needed in Javascript - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to store the number 10 in a variable named score.

Javascript
let score = [1];
Drag options to blanks, or click blank then click option'
A'score'
Bten
Cscore
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around 10 makes it a string, not a number.
Using the variable name instead of a value.
2fill in blank
medium

Complete the code to change the value of the variable score to 20.

Javascript
score [1] 20;
Drag options to blanks, or click blank then click option'
A=
B===
C==
Dequals
Attempts:
3 left
💡 Hint
Common Mistakes
Using == or === instead of = causes comparison, not assignment.
Writing 'equals' is not valid JavaScript syntax.
3fill in blank
hard

Fix the error in the code to declare a variable named name with the value 'Alice'.

Javascript
let [1] = 'Alice';
Drag options to blanks, or click blank then click option'
A1name
BName
Cname
Dna me
Attempts:
3 left
💡 Hint
Common Mistakes
Starting variable names with numbers.
Using spaces inside variable names.
4fill in blank
hard

Fill both blanks to create a variable that stores the sum of 5 and 3.

Javascript
let total = [1] [2] 3;
Drag options to blanks, or click blank then click option'
A5
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus or multiplication instead of addition.
Putting the wrong number or symbol in the blanks.
5fill in blank
hard

Fill all three blanks to create an object with a variable key and value.

Javascript
let [1] = 'color';
let [2] = 'blue';
let obj = { [[1]]: [2] };
Drag options to blanks, or click blank then click option'
Akey
Bvalue
Ccolor
Dblue
Attempts:
3 left
💡 Hint
Common Mistakes
Using the string 'color' as a variable name directly.
Mixing up variable names and their values.