Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2022-04-04T09:15:30+00:00 → 2022-04-05T06:54:09+00:00
| − | TODO: Mach was |
| + | <language>Javascript</language> |
| + | Folie 9.1: |
| + | |
| + | <code id="624b09b4364d3"> |
| + | function letterCount(word){ |
| + | if(word.length == 3){ |
| + | console.log(true) |
| + | }else{ |
| + | console.log(false) |
| + | } |
| + | } |
| + | </code> |
| + | <run id="624b09b436583"> |
| + | letterCount("bab") |
| + | letterCount("b") |
| + | </run> |
| + | |
| + | Folie 9.2: |
| + | |
| + | <code id="624b09b43652e"> |
| + | function startChar(word){ |
| + | if(word.charAt(0) == 'a'){ |
| + | console.log(true) |
| + | }else{ |
| + | console.log(false) |
| + | } |
| + | } |
| + | </code> |
| + | <run id="624b09b4365cf"> |
| + | startChar("abbbba") |
| + | startChar("baaaab") |
| + | </run> |
| + | |
| + | Folie 15.1: |
| + | |
| + | <code id="624b0f55670d8"> |
| + | function even(n){ |
| + | return n * 2 |
| + | } |
| + | </code> |
| + | <run id="624b0f556712e"> |
| + | console.log(even(4374)) |
| + | </run> |
| + | |
| + | |
| + | Folie 23: |
| + | |
| + | <code id="624b0ce4619aa"> |
| + | |
| + | //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)) |
| + | } |
| + | } |
| + | </code> |
| + | <run id="624b0ce461a22"> |
| + | for(i = 0; i < 30; i++){ |
| + | natNum(i) |
| + | } |
| + | </run> |