Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Last revision Both sides next revision | ||
lehrkraefte:blc:informatik:ffprg1-2024:random [2024/03/01 10:37] Ivo Blöchliger created |
lehrkraefte:blc:informatik:ffprg1-2024:random [2024/03/22 13:29] Ivo Blöchliger [Anleitung] |
||
---|---|---|---|
Line 2: | Line 2: | ||
Die JavaScript-Funktion '' | Die JavaScript-Funktion '' | ||
- | Damit lassen sich aus ganzzahlige Zufallszahlen generieren (Funtion | + | Damit lassen sich aus ganzzahlige Zufallszahlen generieren (Funktion |
<code javascript> | <code javascript> | ||
// Liefert eine ganzzahlige Zufallszahl von 0 bis n-1 | // Liefert eine ganzzahlige Zufallszahl von 0 bis n-1 | ||
Line 15: | Line 15: | ||
==== Anleitung ==== | ==== Anleitung ==== | ||
- | Sie werden | + | Sie werden |
<WRAP todo> | <WRAP todo> | ||
Line 25: | Line 25: | ||
function randIn(a,b) { | function randIn(a,b) { | ||
return Math.floor(Math.random()*(b-a+1))+a; | return Math.floor(Math.random()*(b-a+1))+a; | ||
+ | } | ||
+ | // Test-Code | ||
+ | for (let i=0; i<20; i++) { | ||
+ | console.log(randIn(11, | ||
} | } | ||
</ | </ | ||
Line 48: | Line 52: | ||
return wort.substring(0, | return wort.substring(0, | ||
} | } | ||
+ | // Test-Code | ||
+ | console.log(`vertauschen(' | ||
+ | console.log(`vertauschen(' | ||
</ | </ | ||
</ | </ | ||
Line 73: | Line 80: | ||
return vertauschen(wort, | return vertauschen(wort, | ||
} | } | ||
+ | // Test Code | ||
+ | console.log(wortwuerfeln(" | ||
</ | </ | ||
</ | </ | ||
Line 91: | Line 100: | ||
<WRAP todo> | <WRAP todo> | ||
- | Die letzte Funktion '' | + | Die letzte Funktion '' |
Die Funktion soll wie folgt vorgehen: | Die Funktion soll wie folgt vorgehen: | ||