0
0
Javascriptprogramming~10 mins

Dynamic typing 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 with dynamic typing.

Javascript
let value = [1];
Drag options to blanks, or click blank then click option'
A"hello"
Bnull
Ctrue
D42
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around strings.
Using undefined variables.
2fill in blank
medium

Complete the code to change the variable type dynamically.

Javascript
let data = 10;
data = [1];
Drag options to blanks, or click blank then click option'
A"twenty"
B20
Cfalse
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a number without quotes when a string is needed.
Using boolean instead of string.
3fill in blank
hard

Fix the error by completing the code to convert a number to a string.

Javascript
let num = 5;
let str = num[1];
Drag options to blanks, or click blank then click option'
A* 2
B+ 1
C.toString()
D- 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using arithmetic operators instead of conversion methods.
Forgetting parentheses after method name.
4fill in blank
hard

Fill both blanks to create a variable that changes from boolean to string.

Javascript
let flag = [1];
flag = [2];
Drag options to blanks, or click blank then click option'
Atrue
B"true"
Cfalse
D"false"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes for boolean values initially.
Not using quotes when changing to string.
5fill in blank
hard

Fill all three blanks to create a variable that changes from number to string and then to boolean.

Javascript
let val = [1];
val = [2];
val = [3];
Drag options to blanks, or click blank then click option'
A100
B"100"
Cfalse
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing quotes for numbers.
Using wrong boolean values.