Js exercises

1 flashcards · Other · by lakesare

  1. Write a function so that: console.log('hello'.repeatify(3)); //=> "hellohellohello".

    String.prototype.repeatify = function (nTimes) { const originalString = this; let resultingString = ""; for (let i = 0; i < nTimes; i++){ resultingString += originalString; } return resultingString; } console.log('hello'.repeatify(3));