Learning a new "array" of knowledge, here's a detailed look at what an array is:
var arr1 = [1, 2, 3, 4, 5, 6];
var arr2 = Array (1, 2, 3, 4, 5, 6);
var arr3 = new Array (1, 2, 3, 4, 5, 6);
ARR1[6] = 7;
alert (arr1.length);
At this time the computer should display 7, because finally fill in a 7.
Arr.push () refers to the push to go to a number
Arr.pop () refers to the number of pop-up, the original array of useful this will be ejected, not shown.
Iterate through an array: simply by accessing each element in the array until there are no elements to be accessed.
As a result of yesterday's cold really today go to make up the video really better than the scene to understand, first do not say traversal array. Here are some exercises for the For loop today, understanding:
The thickness of a sheet of paper is 0.0001, folding many times over the height of Mount Everest 8848.
var weight=0.0001;
var i=0;
while (true) {
if (weight>=8848) {
Break
}else{
weight*=2;
i++;
}
} alert (i);
There are a pair of young rabbits, one months after the young rabbit grow into a rabbit, the rabbit one months later into a rabbit and gave birth to a pair of young rabbits, asked how many years later on rabbits, rabbits, rabbits, into the number of rabbits, respectively.
Current month Baby rabbit = last month's Rabbit + last month Bunny
Current month Bunny = Last month's Baby Bunny
Current month into rabbit = last month into rabbit + last month Bunny
var count = prompt ();
var yt = 1;
var xt = 0;
var ct = 0;
for (var i = 2; I <= count; i++) {
var pre_yt = YT;
var pre_xt = XT;
var pre_ct = ct;
var yt = pre_ct + pre_xt;
var xt = Pre_yt;
var ct = pre_ct + pre_xt;
}
Alert (YT + "," + XT + "," + ct ");
Two variable exchange:
var a = 1;
var B = 2;
var C;
c = A;
A = b;
b = C;
Badminton Racket 15 Yuan, the ball 3 yuan, the water 2 yuan. 200 yuan each at least one, how many kinds of possibilities, badminton afraid to buy up to 13, the ball up to buy 66, water up to buy 100.
var count = 0;
for (var i = 1; i <=; i++) {
for (var j = 1; J <=, J + +) {
for (var k = 1; k <=; k++) {
var sum = i * + J * 3 + k * 2;
if (sum = = 200) {
count++;
}
}
}
} alert (count);
Rooster 2, hen 1, chicken half, each of at least one, 100 buy 100 chickens how many possibilities
Cocks up to 50, hens up to 100, chick up to 200
var count = 0;
for (var i = 1; i <=; i++) {
for (var j = 1; J <=, J + +) {
for (var k = 1; k <=; k++) {
var sum = 2*i+1*j+0.5*k;
var str = i + j + k;
if (sum = = && str = = 100) {
count++;
}
}
}
} alert (count);
Pooled 1,2,5 20 Yuan money how many possible
1 Yuan 20 2 yuan 10 5 Yuan 4
var count = 0;
for (var i = 1; i <=; i++) {
for (var j = 1; J <=, J + +) {
for (var k = 1; k <= 4; k++) {
var sum = 1*i+2*j+5*k;
if (sum = = 20) {
count++;
}
}
}
} alert (count);
Today practice these questions, or more practice to find ideas, no problem-solving ideas to give you a and this is similar to the question will not, refueling it! Yesterday, a day, feel the brain to explode, cold feeling really bad.
Arrays and for loops