What Will Be The Output Of The Following Javascript Code If #229
What will be the output of the following JavaScript code if oddsums(5); is executed after the following code snippet?</p> <pre><code class="language-javascript"> function oddsums(n) { let total = 0, result=[]; for(let x = 1; x <= n; x++) { let odd = 2*x-1; total += odd; result.push(total); } return result; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs106 Javascript. It can also be found in gs gs106 Classes and Modules - JavaScript Extentions - Quiz No.1.
What will be the output of the following JavaScript code if oddsums(5); is executed after the following code snippet?
function oddsums(n) { let total = 0, result=[]; for(let x = 1; x <= n; x++) { let odd = 2*x-1; total += odd; result.push(total); } return result; }
Returns [1,4,9,16,25]
Returns [1,2,3,4,5]
Returns [3,6,9,12,15]
Returns [1,3,5,7,9]
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