Use typeof to show the type of the value 7.
Acceptance criteria
- 1.#out should show number.
JavaScript Tutorial · JavaScript Basics
These 10 tasks go with the JavaScript Data Types chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “JavaScript data types define what kind of value a variable can store.” .
1.Report a number's typeexercise · easy · 10 min
Use typeof to show the type of the value 7.
Passes when: #out should show number.
2.Report a string's typeexercise · easy · 10 min · practice plan
Use typeof to show the type of "hello".
Passes when: #out should show string.
3.Convert a string to a numberexercise · easy · 10 min · practice plan
Turn the string "25" into a number and add 5 to it.
Passes when: #out should show 30.
4.Convert a number to a stringexercise · easy · 10 min · practice plan
Turn 99 into a string and show its length.
Passes when: #out should show 2.
5.Check for an arrayexercise · medium · 10 min · practice plan
Show whether [1,2,3] is an array, as true or false.
Passes when: #out should show true.
6.Fix the string additionbug fix · easy · 8 min
Adding two numeric strings joins them instead of summing them.
Passes when: #out should show 8, not 53.
7.Fix the typeof check on an arraybug fix · easy · 8 min · practice plan
This reports "object" instead of confirming an array.
Passes when: #out should show true.
8.Fix the wrong equalitybug fix · easy · 8 min · practice plan
Loose equality makes this comparison true when it should be false.
Passes when: #out should show false.
9.Fix the undefined property readbug fix · easy · 8 min · practice plan
Reading a missing property shows undefined instead of the count.
Passes when: #out should show 3.
10.Fix the number that became textbug fix · easy · 8 min · practice plan
The total is joined as text because one value is a string.
Passes when: #out should show 15, not 105.
Between them these tasks cover Primitive types, typeof and Type conversion.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.