What will be the output of the following code snippet?`<script type="text/javascript" language="javascript">` var a = "Synoverge";var result = a.substring(2, 4);document.write(result); `</script>`noSelect one:a. Synovergeb. noc. noved. vergeClear my choice
Question
What will be the output of the following code snippet?<script type="text/javascript" language="javascript"> var a = "Synoverge";var result = a.substring(2, 4);document.write(result); </script>noSelect one:a. Synovergeb. noc. noved. vergeClear my choice
Solution
The output of the given code snippet will be "no".
Here is the step-by-step explanation:
- The variable
ais assigned the value "Synoverge". - The
substring()method is used on the variableawith the parameters2and4. This means that it will extract the characters starting from index 2 (inclusive) up to index 4 (exclusive). - The extracted substring is assigned to the variable
result. - The
document.write()method is used to display the value ofresult. - Since the characters at index 2 and 3 in the string "Synoverge" are "n" and "o" respectively, the output will be "no".
Similar Questions
28. What is the output of the following JavaScript code?*var fruits = [“apple”, “banana”, “cherry”];var result = fruits.join(” – “);console.log(result);
Write the output of the following JavaScript statements :(i) document.write(1 + ‘‘2’’ + ‘‘2’’);(ii) document.write(‘‘1’’ + ‘‘2’’ + ‘‘2’’);
What will be the output of the following code snippet?
What is the output of following code?var a = 10;function test() { a = 20;}test();console.log(a);Options: Pick one correct answer from below1020
What will be the output of the following code snippet?var a = 1; var b = 0; while (a <= 3) { a++; b += a * 2; print(b); }*4 10 181 2 3None of Above1 4 7
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.