“Working with Strings and Numbers” dives into the fundamentals of string and number manipulation in programming. Understanding string methods, template literals, number parsing, and basic math operations is crucial for data handling and creating dynamic applications. Below are 30 carefully curated multiple-choice questions, divided by topic for a focused learning experience.
toUpperCase()toLowerCase()lengthindexOf()toUpperCase()toLowerCase()charAt()slice()concat()toLowerCase()includes()toUpperCase()trim() method do to a string?
"hello".charAt(1)?
heloincludes()startsWith()indexOf()slice()"JavaScript".indexOf("Script") return?
4056split()slice()trim()toLowerCase()replace() method do in a string?
"hello"?
"hello".toUpperCase()"hello".charAt(0).toUpperCase() + "hello".slice(1)"hello".toUpperCase() + "hello".slice(1)"hello".slice(1)'"{}`const name = "Alice"; const message = Hello, ${name}!;?
Hello, ${name}!Hello, Alice!Hello Alice!${name}, Hello!`The sum is: ${5 + 10}`?
The sum is: 15The sum is: ${5 + 10}The sum is 5 + 10The sum: 15+ between stringsparseInt("20.5")?
2020.5NaNundefinedparseInt()Number()parseFloat()toFixed()isNaN("Hello")?
truefalseNaNundefinedparseInt()Number()isNaN()toString()Number("50") + Number("10.5") return?
6060.5NaN510.5"123" to an integer?
parseInt("123")parseFloat("123")Number("123")All of the aboveparseFloat("10.99abc") return?
10.99NaN10abcNaN?
Number("123a")parseInt("123")parseFloat("123.45")Number("123")parseInt()parseFloat()Math.round()Number()parseInt()Number()toString()isNaN()Math.max(3, 7, 1, 5) return?
1357Math.round()Math.ceil()Math.min()Math.max()Math.sqrt()Math.pow()Math.abs()Math.floor()Math.floor(4.7)?
454.7NaNMath.ceil()Math.floor()Math.round()parseInt()| Qno | Answer |
|---|---|
| 1 | C) length |
| 2 | A) toUpperCase() |
| 3 | B) toLowerCase() |
| 4 | C) Removes whitespace from both ends |
| 5 | B) e |
| 6 | B) startsWith() |
| 7 | A) 4 |
| 8 | A) split() |
| 9 | B) Replaces the first occurrence of a substring with a new string |
| 10 | B) “hello”.charAt(0).toUpperCase() + “hello”.slice(1) |
| 11 | D) ` |
| 12 | B) Hello, Alice! |
| 13 | B) Interpolation of variables |
| 14 | A) The sum is: 15 |
| 15 | D) Using template literals |
| 16 | A) 20 |
| 17 | C) parseFloat() |
| 18 | A) true |
| 19 | C) isNaN() |
| 20 | B) 60.5 |
| 21 | D) All of the above |
| 22 | A) 10.99 |
| 23 | A) Number(“123a”) |
| 24 | C) Math.round() |
| 25 | C) toString() |
| 26 | D) 7 |
| 27 | C) Math.min() |
| 28 | A) Math.sqrt() |
| 29 | A) 4 |
| 30 | A) Math.ceil() |