0
0
Javascriptprogramming~20 mins

Dynamic typing in JavaScript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JavaScript Dynamic Typing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this code with dynamic typing?
Consider the following JavaScript code. What will be printed to the console?
Javascript
let x = '5';
x = x + 3;
console.log(x);
Aundefined
B8
CTypeError
D"53"
Attempts:
2 left
💡 Hint
Remember that + operator with a string converts the other operand to string.
Predict Output
intermediate
2:00remaining
What is the type of variable after reassignment?
What will be the output of the following code?
Javascript
let data = 10;
data = 'hello';
console.log(typeof data);
A"number"
B"undefined"
C"string"
D"object"
Attempts:
2 left
💡 Hint
Variables in JavaScript can hold any type and can be reassigned.
Predict Output
advanced
2:00remaining
What is the output of this dynamic type coercion?
What will this code print to the console?
Javascript
console.log('5' - 3);
A2
B"53"
CNaN
DTypeError
Attempts:
2 left
💡 Hint
The - operator converts strings to numbers if possible.
Predict Output
advanced
2:00remaining
What error does this code raise due to dynamic typing?
What happens when this code runs?
Javascript
let a = null;
console.log(a.toUpperCase());
ATypeError
Bnull
Cundefined
DSyntaxError
Attempts:
2 left
💡 Hint
null has no methods and cannot be used like a string.
🧠 Conceptual
expert
3:00remaining
Which option shows the correct dynamic type change and output?
Which code snippet will output the number 10 after dynamic typing changes?
Alet val = '5'; val = val - '5'; console.log(val);
Blet val = '5'; val = +val + 5; console.log(val);
Clet val = 5; val = val + '5'; console.log(val);
Dlet val = '5'; val = val + 5; console.log(val);
Attempts:
2 left
💡 Hint
The unary + converts string to number before addition.