Loops

Qus. 1 : Which loop is guaranteed to execute at least one time, regardless of the condition?

  1. for loop
  2. while loop
  3. do-while loop
  4. None of the above
Qus. 2 : What is the correct syntax for a for loop?

  1. for (i = 0; i < 5; i++) { // code }
  2. for (i <= 5; i++) { // code }
  3. for i = 1 to 5 { // code }
  4. for (i = 0; i < 5) { // code }
Qus. 3 : Which of the following is true about the break and continue statements in JavaScript?

  1. break statement stops the loop, and continue skips the current iteration
  2. continue statement stops the loop, and break skips the current iteration
  3. Both break and continue stop the loop
  4. Both break and continue skip the current iteration
Qus. 4 : Can we nest loops in JavaScript?

  1. Yes, but only two levels deep
  2. No, nesting loops is not allowed
  3. Yes, we can nest any number of loops
  4. Yes, but only with for loops
Qus. 5 : Which loop is most appropriate when the number of iterations is known beforehand?

  1. for loop
  2. while loop
  3. do-while loop
  4. foreach loop
Qus. 6 : <p>What will be the output of the following JavaScript code?</p><pre><span style="font-size: 14px;">let i = 0;<br></span><span style="font-size: 14px;">while(i &lt; 3) {<br></span><span style="font-size: 14px;">&nbsp; console.log(i);<br></span><span style="font-size: 14px;">&nbsp; i++;<br></span><span style="font-size: 14px;">}</span></pre>

  1. 0 1 2
  2. 1 2 3
  3. 0 1 2 3
  4. 1 2

Programs

JavaScript script to display the current day and time in the following format

View Solution


JavaScript function to extract unique characters from a string

View Solution


Write a JavaScript program which accept a string as input and swap the case of each character.

View Solution


calculator program in javascript

View Solution


JavaScript code to print current date in dd mon year format

View Solution


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad