JS: Odd and even numbers between 1-100 and Monday weekdays and Rest days (switch method)

Source: Internet
Author: User

The odd and even numbers between   1-100 and the variable  let odd = 0; let even = 0; for (i = 1; i<=; i++) { if (i% 2 = = = 0) {  assignment even+=i;} else{odd+=i;}  } console.log (' Even and ' + ' ${even} ', ' odd and ' + ' ${odd} '); Determine whether the number of user input is prime  console.log (' Please enter a number: ');  let num = Readline.question (); Let Falg = 1;for (Let i = 2; i < num; i++) { if (num% i ===0) { console.log (num + ' Not prime number ');  falgt=0; break; } } if (falg) { console.log (num+ ' is prime number ');} Let arr = [[' A ', ' B '], [' C ', ' d ', ' E ',]];for (let me = 0; i < arr.length; i++) { for (Let j = 0; J < Arr[i].leng Th J + +) {Console.log (arr[i][j]);}  }   //prompts the user to enter any number between 1-7, judging and outputting whether it is a working day or a rest day. Do  console.log with switch (' Please enter any number between 1 and 7 ')  let day = Readline.question (")-0; switch (day) { case 1:& Nbsp;case 2: case 3: case 4: case 5: console.log (' weekday ');  break; case 6:  Console.log (' rest day ');  case 7: console.log (' rest day '); break; Default: console.log (' incorrect input ');  }

JS: Odd and even numbers between 1-100 and Monday weekdays and Rest days (switch method)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.