Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
84
rated 0 times [  88] [ 4]  / answers: 1 / hits: 17327  / 7 Years ago, tue, may 16, 2017, 12:00:00

I'm running a code where I must create a function and call it multiple times. I am having trouble calling it more than once. how can i solve this? im writing in javascript. So I create a function called beCheerful(); within it must be a string 'good morning!' called 98 times. Please help. It would be very much appreciated.


More From » javascript

 Answers
10
function beCheerful() {
console.log('good morning');
}

for (var i = 0; i < 98; i++) {
beCheerful();
}


This will loop from 0 to 97, calling beCheerful each time. There are a few types of loops: for, while, do-while, forEach... in Javascript. You should read up on them.


[#57767] Sunday, May 14, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jameson

Total Points: 534
Total Questions: 103
Total Answers: 102

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;