String length property
What is the result of 'JavaScript'.length?
- 8
- 10
- 9
- 12
- 11
Finding character position in a string
Which method returns the index of the first occurrence of 'a' in the string 'banana'?
- charAt
- locate
- indexOf
- getIndex
- findChar
Changing string case
What does 'hello world'.toUpperCase() return?
- Hello world
- Hello_world
- hello world
- Hello World
- HELLO WORLD
Checking substring presence
Which method checks if 'fun' exists within the string 'Have fun coding'?
- includes
- inString
- test
- find
- hasString
Extracting part of a string
What method would you use to extract 'Script' from 'JavaScript'?
- substring
- parse
- extract
- explode
- split
Template literals
What will be the output of `The answer is ${6 + 4}` using template literals?
- The answer is ${6+4}
- The answer is 64
- The answer is six plus four
- The answer is {6+4}
- The answer is 10
Creating numbers from strings
Which method will convert the string '123' into a number?
- parseChar
- stringToNum
- Number
- numValue
- toDigit
Number to fixed decimals
What does (3.14159).toFixed(2) return?
- 3.141
- 3.14
- 3
- 3.1
- 3.142
NaN explanation
What does 'NaN' stand for in JavaScript?
- Number as Null
- Null at Number
- New as Needed
- Not a Number
- Negative and Null
Absolute values
Which Math object method returns the positive value of a number, such as Math.abs(-5)?
- Math.value
- Math.abs
- Math.absolute
- Math.absval
- Math.positive
Rounding numbers
Which Math method rounds 5.7 up to the nearest integer?
- Math.up
- Math.round
- Math.trunc
- Math.floor
- Math.ceil
Random number generation
What does Math.random() produce in JavaScript?
- A random negative number
- A random integer between 0 and 100
- A random floating-point number between 0 (inclusive) and 1 (exclusive)
- A random decimal from 1 to 10
- A random boolean value
Getting the current date
Which code creates a Date object representing the current date and time?
- createDate()
- getDate()
- new Date()
- Date.now()
- Date.today()
Extracting year from Date object
Given a Date object 'now', which method retrieves the full year (e.g., 2024)?
- getDateYear
- getYear
- fetchYear
- fullYear
- getFullYear
String trimming
What does the 'trim()' method do to a string such as ' hello '?
- Converts text to lowercase
- Removes all spaces
- Extracts the first word
- Removes whitespace from both ends
- Joins strings together