Reputation: 57
So i'm creating a timer and so far it does what it needs, displays the correct time between the two clicks of OK's, but now i want into change the output colour to green if it's below 0.5 seconds, i've tried below to do this but the colour doesn't change any solutions would be helpful.
Extra: I would also like to have Else IF statement for 0.5-1 seconds to be orange and anything over 1 second as red. Any guidance would be great
var canvas;
canvas = openGraphics();
alert("Press \"OK\" to start the timer.");
var starttime = Date.now();
alert("Press \"OK\" to stop the timer.");
var stoptime = Date.now();
var seconds_between = (stoptime - starttime) / 1000;
alert(seconds_between + " seconds");
var phrase1;
phrase1 = " seconds.";
var message;
message = seconds_between + phrase1;
if (seconds_between < 0 || seconds_between > 0.50) {
message.fontcolor("green");
}
canvas.drawString(message, 10, 10);
canvas.paint();
Upvotes: 0
Views: 74
Reputation: 106
if (seconds_between < 0 || seconds_between > 0.50) {
message.fontcolor("green");
}
needs to be
if (seconds_between > 0 || seconds_between < 0.50) {
message.fontcolor("green");
}
Upvotes: 1