0
0
Javascriptprogramming~10 mins

Variable declaration using var in Javascript - Interactive Code Practice

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

Complete the code to declare a variable named age using var.

Javascript
var [1] = 25;
Drag options to blanks, or click blank then click option'
Anumber
Blet
Cconst
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using keywords like let or const instead of the variable name.
Using a number or type instead of a variable name.
2fill in blank
medium

Complete the code to declare a variable named name and assign it the value 'Alice' using var.

Javascript
var [1] = 'Alice';
Drag options to blanks, or click blank then click option'
Alet
Bconst
Cname
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using let or const instead of the variable name.
Using a type name like string instead of the variable name.
3fill in blank
hard

Fix the error in the code by completing the variable declaration with var.

Javascript
[1] score = 100;
Drag options to blanks, or click blank then click option'
Avar
Blet
Cconst
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the keyword var.
Using let or const instead of var.
4fill in blank
hard

Fill both blanks to declare two variables x and y using var and assign them values 5 and 10.

Javascript
var [1] = 5, [2] = 10;
Drag options to blanks, or click blank then click option'
Ax
Bvar
Cy
Dlet
Attempts:
3 left
💡 Hint
Common Mistakes
Using let instead of var.
Using the keyword var twice.
Using wrong variable names.
5fill in blank
hard

Fill all three blanks to declare variables a, b, and c using var and assign them values 1, 2, and 3.

Javascript
var [1] = 1, [2] = 2, [3] = 3;
Drag options to blanks, or click blank then click option'
Aa
Bb
Cc
Dlet
Attempts:
3 left
💡 Hint
Common Mistakes
Using let instead of var.
Using wrong variable names or order.
Missing commas between variables.