Loop Help Needed

// DO NOT CHANGE THE TWO LINES BELOW.
const str = prompt("Enter a string: ");
const n = prompt("Enter a number: ");

/**

  • TODO: Creates a new string that repeats the given string str
  • n number of times. Each one should be in its own line.
  • For example: if str is ‘Hello!’, and n is 3, then it should
  • be ‘Hello!\nHello!\nHello!\n’
    */
    let result = undefined;

// DO NOT CHANGE THE LINE BELOW.
console.log(result);

Use a for loop.

for(let i = 0; i < n; i++) {
 //do work here
}

You’re a generous human being.

“Each one should be in its own line.”
I have no idea how to do this part. How to print in its own line?

Use the new line escape character, ‘\n’, like shown in the quote above.