Migrate docs from the other repo
This commit is contained in:
30
docs/reference/js/lessons/running-time/challenges.md
Normal file
30
docs/reference/js/lessons/running-time/challenges.md
Normal file
@ -0,0 +1,30 @@
|
||||
# running time challenges
|
||||
|
||||
My script. #docs
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
Great job! You have successfully completed the [Running Time tutorial](/microbit/lessons/running-time/tutorial) . You have a forever loop that declares a variable in it that holds the running time in milliseconds of the micro:bit and then shows the seconds on the LED screen.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let now = input.runningTime()
|
||||
basic.showNumber(now / 1000, 150)
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
When button A is pressed, reset the time by subtracting the current time from the variable now.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let now1 = input.runningTime()
|
||||
basic.showNumber(now1 / 1000, 150)
|
||||
})
|
||||
if (input.buttonIsPressed("A")) {
|
||||
let now2 = 0 // ***
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
Reference in New Issue
Block a user