Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to Solve chapter 8 of question no. 1 of JavaScript to execute a function 3 times?

function teaBreak(){
console.log("Start making tea");
console.log("Tea ready");
console.log("Enjoy the tea");
console.log("-------");
}

let teaHour;

for(teaHour=1; teaHour<=12; teaHour++)
{
if(teaHour == 0)
{
teaBreak();
}
}
by

1 Answer

sam5epi0l
You have to use teaHour%4 instead of teaHour like shown in the following code.

function teaBreak(){
console.log("Start making tea");
console.log("Tea ready");
console.log("Enjoy the tea");
}

let teaHour;

for(teaHour=1; teaHour<=12; teaHour++)
{
if(teaHour%4 == 0)
{
teaBreak();
}
}

Login / Signup to Answer the Question.