Exercises from Liaoche JavaScript tutorial

Source: Internet
Author: User

Cycle

Using for 1 * 2 * 3 * ... * 10 The results of a cyclic calculation:

' Use strict '; var x = 1; var i;  for (i=1;i<=10;i++) {x=x*i;} if (x = = 3628800) {    console.log (' 1 x 2 x 3 x ... x = ' + x ' );} Else {    console.log (' calculation error ');}
View Code

Use loops to iterate through each name in the array and display Hello, xxx! :

' Use strict '; var arr = [' Bart ', ' Lisa ', ' Adam '];arr.sort ();   // Positive Order // reverse Arr.reverse ();  for (var i=0;i<arr.length;i++) {console.log (' hello,${arr[i]} ');} var i=0;  while (i<arr.length) {console.log (' hello,${arr[i]} '); I+ +;}
View Code

Exercises from Liaoche JavaScript tutorial

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.