-2

im suppose to return the word concatenated into itself n number of times it keeps coming out as nan I don't know what im doing wrong . the word is supposed to print to the console like this HelloHelloHello’ if I pass in Hello and the number 3.

function pere(word ,n) {
    return  word * n  ;
 
}

console.log (pere("hello", 3));

function pere(word ,n) {
    return  word * n  ;
 
}

console.log (pere("hello", 3));

function pere(word ,n) {
    return  (word * n)  ;
 
}

console.log ((hello)(3));
Filburt
  • 17,626
  • 12
  • 64
  • 115
dev
  • 1
  • 1
  • Javascript != python! See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat – gog Nov 17 '22 at 10:41

1 Answers1

0

This would work.

function pere(word, n){
  console.log(word.repeat(n));
}
Shawn
  • 146
  • 7