JavaScript Data Types and Conversions Quiz

Create an account and save your quiz results

Login and save your results

OR

Question 1/15

What does `parseFloat("12.34abc")` return in JavaScript?
parseFloat("12.34abc")

Select your answer

Question 2/15

What value is returned by the expression `Number(undefined)` in JavaScript?
Number(undefined)

Select your answer

Question 3/15

How do you convert a string `"123"` to a number in JavaScript?

Select your answer

Question 4/15

What result will `typeof undefined` produce?
typeof undefined

Select your answer

Question 5/15

What does `parseInt("10.5")` return in JavaScript?
parseInt("10.5")

Select your answer

Question 6/15

What is the result of the expression `typeof null` in JavaScript?
typeof null

Select your answer

Question 7/15

What will `Boolean(" ")` return?
Boolean(" ")

Select your answer

Question 8/15

What is the result of `"5" - 1` in JavaScript?
"5" - 1

Select your answer

Question 9/15

In JavaScript, which type of loop will run at least once no matter what?

Select your answer

Question 10/15

Which of the following is a primitive data type in JavaScript?

Select your answer

Question 11/15

What is the value of `Number('123abc')` in JavaScript?
Number('123abc')

Select your answer

Question 12/15

Which statement will create an object from an empty object in JavaScript?
let obj = {};

Select your answer

Question 13/15

Which JavaScript type has no methods or properties of its own?

Select your answer

Question 14/15

Which JavaScript function would you use to combine variable `let a = 'Hello'; let b = 'World';` into a single output 'Hello World'?
let a = 'Hello';
let b = 'World';

Select your answer

Question 15/15

What is the value of `Boolean("false")` in JavaScript?
Boolean("false")

Select your answer

Your Results

You did not answer any questions correctly.

Your Answers

Question 1/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does `parseFloat("12.34abc")` return in JavaScript?
parseFloat("12.34abc")

Available answers

The `parseFloat` function converts a string to a floating-point number up to the first invalid character. Thus, `parseFloat("12.34abc")` returns `12.34`.
Question 2/15
😊 Your answer was correct 🙁 Your answer was incorrect
What value is returned by the expression `Number(undefined)` in JavaScript?
Number(undefined)

Available answers

The `Number` function converts the value to a number. If it can't be converted to a number, it will return `NaN`. `undefined` is converted to `NaN`.
Question 3/15
😊 Your answer was correct 🙁 Your answer was incorrect
How do you convert a string `"123"` to a number in JavaScript?

Available answers

You can convert a string to a number using the `Number` function, like so: `Number("123")`.
Question 4/15
😊 Your answer was correct 🙁 Your answer was incorrect
What result will `typeof undefined` produce?
typeof undefined

Available answers

In JavaScript, the `typeof` operator used on `undefined` returns `"undefined"`.
Question 5/15
😊 Your answer was correct 🙁 Your answer was incorrect
What does `parseInt("10.5")` return in JavaScript?
parseInt("10.5")

Available answers

The `parseInt` function converts a string to an integer. It parses up to the first invalid character for an integer, so `parseInt("10.5")` returns `10`.
Question 6/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the result of the expression `typeof null` in JavaScript?
typeof null

Available answers

In JavaScript, `typeof null` returns `"object"`. This is a well-known bug in JavaScript introduced in the first version of the language.
Question 7/15
😊 Your answer was correct 🙁 Your answer was incorrect
What will `Boolean(" ")` return?
Boolean(" ")

Available answers

The `Boolean` conversion of any non-empty string will return `true`, including a space character.
Question 8/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the result of `"5" - 1` in JavaScript?
"5" - 1

Available answers

In JavaScript, the `-` operator converts operands to numbers if they're not, so `"5" - 1` evaluates to `4`.
Question 9/15
😊 Your answer was correct 🙁 Your answer was incorrect
In JavaScript, which type of loop will run at least once no matter what?

Available answers

A `do...while` loop will execute the block of code at least once before checking the condition.
Question 10/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which of the following is a primitive data type in JavaScript?

Available answers

Strings, numbers, booleans, null, and undefined are the primitive data types in JavaScript. `String` is one of them.
Question 11/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the value of `Number('123abc')` in JavaScript?
Number('123abc')

Available answers

The `Number` function returns `NaN` when a string cannot be converted to a number. Since `'123abc'` is not a valid number, the result is `NaN`.
Question 12/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which statement will create an object from an empty object in JavaScript?
let obj = {};

Available answers

`Object.assign` can be used to copy all enumerable properties from one (or more) source objects to a target object. `Object.assign(obj)` will just return `obj` if it doesn't have another source object.
Question 13/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which JavaScript type has no methods or properties of its own?

Available answers

`Undefined` is a primitive data type in JavaScript, which has no properties or methods.
Question 14/15
😊 Your answer was correct 🙁 Your answer was incorrect
Which JavaScript function would you use to combine variable `let a = 'Hello'; let b = 'World';` into a single output 'Hello World'?
let a = 'Hello';
let b = 'World';

Available answers

In JavaScript, you use `a.concat(' ', b)` to combine two strings.
Question 15/15
😊 Your answer was correct 🙁 Your answer was incorrect
What is the value of `Boolean("false")` in JavaScript?
Boolean("false")

Available answers

When a string that is not empty (including the string "false") is converted to a boolean in JavaScript, it results in `true`. Non-empty strings are truthy values.