What Will Be The Output Of The Following Javascript Codep Pre #108
What will be the output of the following JavaScript code?</p> <pre><code class="language-javascript"> const array = [1, 2, 3, 4, 5]; const startIndex = 1; const endIndex = 3; const portionToReverse = array.slice(startIndex, endIndex + 1); portionToReverse.reverse(); for (let i = startIndex, j = 0; i <= endIndex; i++, j++) { array[i] = portionToReverse[j]; } console.log(array); document.writeln(rev); </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs106 Javascript. It can also be found in gs gs106 Lexical Structures - JavaScript Array and Related Methods - Quiz No.2.
What will be the output of the following JavaScript code?
const array = [1, 2, 3, 4, 5]; const startIndex = 1; const endIndex = 3; const portionToReverse = array.slice(startIndex, endIndex + 1); portionToReverse.reverse(); for (let i = startIndex, j = 0; i <= endIndex; i++, j++) { array[i] = portionToReverse[j]; } console.log(array); document.writeln(rev);
1, 2, 3, 4, 5
1, 4, 3, 2, 5
1, 5, 4, 3, 2
5, 4, 3, 2, 1
Similar question(s) are as followings:
Online Quizzes of gs106 Javascript
Graphics and Rendering in JavaScript - Scripted Media - Quiz No.1
gs gs106 Javascript
Online Quizzes