0
Predict the output of the following JavaScript code. <script type="text/javascript"> var a="blogsforblog"; var x=a.lastIndexOf("b"); document.write(x); </script>

Open 1 Answers 94 Views Technology
Predict the output of the following JavaScript code.

<script type="text/javascript">

var a="blogsforblog";

var x=a.lastIndexOf("b");

document.write(x);

</script>

A) 8

B) 0

C) 9

D) Error

1 Answer

0
Ans: A

Explanation: The index starts with 0 in JavaScript. Here, x searches for the last occurrence of “b” in the text.
by (279k points)
...