Challenge - 5 Problems
Built-in Methods Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
β Predict Output
intermediate2:00remaining
Output of Array map with built-in method
What is the output of this code?
const numbers = [1, 2, 3, 4]; const doubled = numbers.map(Math.sqrt); console.log(doubled);
Javascript
const numbers = [1, 2, 3, 4]; const doubled = numbers.map(Math.sqrt); console.log(doubled);
Attempts:
2 left
π‘ Hint
Math.sqrt returns the square root of a number.
β Incorrect
The map method applies Math.sqrt to each number, so the output is the square root of each element.
β Predict Output
intermediate2:00remaining
Output of String built-in method
What is the output of this code?
const text = 'Hello World'; const result = text.toUpperCase(); console.log(result);
Javascript
const text = 'Hello World'; const result = text.toUpperCase(); console.log(result);
Attempts:
2 left
π‘ Hint
toUpperCase converts all letters to uppercase.
β Incorrect
The toUpperCase method converts all letters in the string to uppercase.
β Predict Output
advanced2:00remaining
Output of Array filter with built-in method
What is the output of this code?
const values = [10, 15, 20, 25, 30]; const filtered = values.filter(x => x % 20 === 0); console.log(filtered);
Javascript
const values = [10, 15, 20, 25, 30]; const filtered = values.filter(x => x % 20 === 0); console.log(filtered);
Attempts:
2 left
π‘ Hint
filter keeps elements where the function returns true.
β Incorrect
Only 20 is divisible by 20 with no remainder, so the filtered array contains only 20.
β Predict Output
advanced2:00remaining
Output of Object.keys built-in method
What is the output of this code?
const obj = {a: 1, b: 2, c: 3};
const keys = Object.keys(obj);
console.log(keys);Javascript
const obj = {a: 1, b: 2, c: 3}; const keys = Object.keys(obj); console.log(keys);
Attempts:
2 left
π‘ Hint
Object.keys returns an array of property names.
β Incorrect
Object.keys returns an array of the object's own property names as strings.
β Predict Output
expert3:00remaining
Output of chaining built-in methods
What is the output of this code?
const sentence = ' JavaScript is fun ';
const result = sentence.trim().split(' ').filter(word => word.length > 2).join('-');
console.log(result);Javascript
const sentence = ' JavaScript is fun '; const result = sentence.trim().split(' ').filter(word => word.length > 2).join('-'); console.log(result);
Attempts:
2 left
π‘ Hint
trim removes spaces, split divides words, filter removes short words, join connects with dashes.
β Incorrect
trim() removes leading/trailing spaces: 'JavaScript is fun'. split(' ') gives ['JavaScript', 'is', 'fun']. filter(word => word.length > 2) removes 'is' (length 2), leaving ['JavaScript', 'fun']. join('-') gives 'JavaScript-fun'.