meta data for this page


This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
courses:ct30a3201:veronika_hoeoek [2013/09/01 15:14]
courses:ct30a3201:veronika_hoeoek [2013/09/05 17:59] (current)
Line 10: Line 10:
 **30.8.2013**Tein vähän muuttujin osaa. **30.8.2013**Tein vähän muuttujin osaa.
-Variables eli muttujat. ​First declare the function. ​+Variables eli muttujat.**Functions**:​ first declare the function. ​
 var function_name=function(parameter eli input) var function_name=function(parameter eli input)
Line 34: Line 34:
  ​{return "​scissors";​}  ​{return "​scissors";​}
 +**for** syntax: for (variable initial condition; variable end condition; counter that counts rounds)
 +{do sth};
 +Counter: Rising i=i+1 or i++  , Decreasing i=i-1 or i-- , Up any value(3) i+=3 , Down any value(3) i-=3. **for** silmukkat pyörivät vain silloin kun ehto on totta, HUOM! jos ehto on aina totta-> infinitive loop
 +  * store **lists** of data
 +  * can store **different** data types
 +  * are **ordered** (position of each piece of data is fixed
 +Esimerkki: var names = ["​Mia",​ 1, "​L"​];​ var arrayName = [data, data, data]; **Get access to data** -> arrayName [position number in the array]. Position counts starting from 0 !!!  Esimerkiksi: ​ jokuData[0]= first element, jokuData[2] = third element. Systematic acess of array- for loop! 
 +var roads = ["​...",​ "​...",​ "​...",​ "​..."​]; ​
 +for (var i=0; i<​roads.length;​ i++){
 +console.log ("​I..."​+roads[i])}; ​
 +**Suurimman elementin löytäminen** eli **Finding largest element**: assign initial largest value: var largest =0; ->then compare
 +HUOM! silloin kun laitetaan arvo muuttajalle ​ (assign value to variable) tarvitaan vain yksi = yhtäsuurimerkin ​    !