I have a student who wants to code an object growing and shrinking while someone breathes in and out. Here is some of their code.
Is this the best way to do this?
var pause = 0;
var setShapeSize = 50;
function StartBreathing() {
function breatheIn() {
for (var size = 50; size <= 100; size += 1) {
setShapeSize(size);
pause(10);
}
}
function breatheOut() {
for (var size = 100; size >= 50; size -= 1) {
setShapeSize(size);
pause(10);
}
}
}
function StartBreathing() {
while (true) {
breatheIn();
breatheOut();
}
}