exercise: repetition

Asked

Viewed 700 times

1

I am having difficulty in the following exercise: Make a function call printAzul4 that shows 4 times the word Blue. (required to use for)

I can do the code just by using the for, but I can’t turn it into a function.

The resolution should be in javascript

for(var i = 0; i < 4; i++) {
   console.log("Azul")
}

1 answer

6

You just need to put your code on função as below:

function imprimirAzul4(){
for(var i = 0; i < 4; i++) {
   console.log("Azul")
}
}

Then just run the function with a button or something.

  • Wow! Thank you! I thought I would have to put some parameter in the function! Thank you again

Browser other questions tagged

You are not signed in. Login or sign up in order to post.