My students want to code a timer feature into their apps in app lab. As in, a countdown. How do they do this?
Thanks,
Jason
My students want to code a timer feature into their apps in app lab. As in, a countdown. How do they do this?
Thanks,
Jason
Hi @jmahoney,
What a cool idea for an app! I would ask the student to think through the following:
If you & the student think through this and realize you need more specific help with a certain step, please feel free to ask us on this thread.
Hope that helps!
–Michael K.
Look at the control category. There is a block timedLoop
. I would guess that it isn’t very accurate but definitely close enough for government work. 1
1 An example of government work would be when I was working at the cruise missile plant. I was looking at a program that made calculations as part of the project that would deliver nuclear weapons. It was wrong, had a bug. I talked to the engineers about it and they didn’t care. It was close enough for government work.
well that’s specifically if your working in blocks, however may I suggest setTimeout? I’ll show my example below
/*
* setTimeout(callback: Function, delay: number)
*/
setTimeout(function() {
console.log("hello world")
}, 1000)
by using this method you can easily set a timer for as long as needed, however if you wish to make a consistent timer that counts down all the time showing progress, I believe @jdonwells solution would be better than mine
Hope this helps!