
Apu
February 20, 2023 ›
#Javascript
›
#Q&A
❌
Which of the following is the correct output for the following JavaScript code?
- A) "ello Wo"
- B) "llo Wo"
- C) "lo Wo"
- D) "World"
<script> let myStr = "Hello World"; let output = myStr.slice(2, 8); console.log(output); </script>
If you run the above code, the output will be "ello Wo", which is option B) in the multiple choice question.
Explanation: The slice() method returns a part of the string starting from the index indicated by the first argument up to, but not including, the index indicated by the second argument. In this case, the start index is 2 and the end index is 8, so the output is "llo Wo".
save
listen
AI Answer
Which of the following is the correct output for the following JavaScript code?
0
A) "ello Wo" B) "llo Wo" C) "lo Wo" D) "World" <…
asked
Apu
0 answers