Change docs to randomInt

This commit is contained in:
Sam El-Husseini
2018-04-21 10:52:09 -07:00
parent 99a28e59f1
commit 6b9e78d269
61 changed files with 152 additions and 152 deletions

View File

@ -200,14 +200,14 @@ Review the use of the random block in the Math category.
* Create a block that will plot a single dot at a random location on the screen by choosing a random number from 0 to 4 for the x axis and a random number from 0 to 4 for the y axis.
```blocks
led.plot(Math.random(5), Math.random(5))
led.plot(Math.randomInt(5), Math.randomInt(5))
```
Next, lets create a loop that will repeat the above code five times, for a constellation with five stars.
```blocks
for (let index = 0; index <= 4; index++) {
led.plot(Math.random(5), Math.random(5))
led.plot(Math.randomInt(5), Math.randomInt(5))
}
```
@ -238,7 +238,7 @@ To fix this, we need to do a little math by subtracting 1 from whatever the valu
let list = [5, 2, 1, 3, 4]
for (let index = 0; index < list[0] - 1; index++) {
led.plot(Math.random(5), Math.random(5))
led.plot(Math.randomInt(5), Math.randomInt(5))
}
```
@ -253,7 +253,7 @@ let list: number[] = []
input.onButtonPressed(Button.A, () => {
for (let i = 0; i <= list.length - 1; i++) {
for (let j = 0; j <= list[i] - 1; j++) {
led.plot(Math.random(5), Math.random(5))
led.plot(Math.randomInt(5), Math.randomInt(5))
}
basic.pause(1000)
basic.clearScreen()

View File

@ -62,7 +62,7 @@ let column = 0
let index = 0
input.onButtonPressed(Button.AB, () => {
for (let index = 0; index <= 4; index++) {
list[index] = Math.random(5) + 1
list[index] = Math.randomInt(5) + 1
}
})
input.onButtonPressed(Button.B, () => {
@ -142,7 +142,7 @@ input.onButtonPressed(Button.B, () => {
})
input.onButtonPressed(Button.AB, () => {
for (let index = 0; index <= 4; index++) {
list[index] = Math.random(5) + 1
list[index] = Math.randomInt(5) + 1
}
})
input.onButtonPressed(Button.A, () => {
@ -223,7 +223,7 @@ input.onButtonPressed(Button.A, () => {
})
input.onButtonPressed(Button.AB, () => {
for (let index = 0; index <= 4; index++) {
list[index] = Math.random(5) + 1
list[index] = Math.randomInt(5) + 1
}
})
input.onButtonPressed(Button.B, () => {