- 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".
Comments (0)