Folie 9.1:
function letterCount(word){ if(word.length == 3){ console.log(true) }else{ console.log(false) } }
letterCount("bab") letterCount("b")
ausführen
Folie 9.2:
function startChar(word){ if(word.charAt(0) == 'a'){ console.log(true) }else{ console.log(false) } }
startChar("abbbba") startChar("baaaab")
Folie 15.1:
function even(n){ return n * 2 }
console.log(even(4374))
Folie 23:
//Funktion even(n) von Folie 15 function odd(n){ return n * 2 + 1 } function natNum(i){ if(i % 2 == 0){ console.log(even(i/2)) }else{ console.log(odd((i-1)/2)) } }
for(i = 0; i < 30; i++){ natNum(i) }