Don't know how to name it 😁x3

check out this simple code
it prints this sentence(in const keyword) times as a number of characters we have in function’s parameter

var printManyTimes = function (str) {
    const SENTENCE = str + 'is fun';
    for (let i = 0; i < str.length; i++) {


printManyTimes('Coding ');

my question is, is it possible to use return type for such qn and print the output while calling it

like return SENTENCE then do

console.log(printManyTimes('Coding '));

1 Like

return exit the function, your loop would execute only once. You can create a string or an array of strings with the various repetitions, return that, and in this case you can print the resulto of the function with the various repetitions

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


1 Like