Print This Pattern In JavaScript, 11111 2222 333 44 5, Ask The User For Number Of Lines To Be Printed

LEVEL: Beginner

Whats in this post?

  1. Code
  2. Output
  3. Background and Explanation of the code

Code


To copy code: Click  View Source “View Source” on the right of this code snippet.


Background and Explanation of the code


  1. A JavaScript prompt box has been used to input the number of lines up to which the pattern will be printed.
  2. Two nested ‘for’ loops have been used to print the desired pattern. Variable ‘temp’ has been used for temporary storage.