how do i test this function in javascripts? function repeat(text,n) { result=""; for(var i=0; i "cowcowcow" repeat( "alf", 10 ) => "alfalfalfalfalfalfalfalfalfalf" repeat( "repeat", -3...


how do i test this function in javascripts?



function repeat(text,n) {
    result="";
    for(var i=0; i
        result+=text;
    }
    return result;
}



the instructions are as follows


This function accepts a string (text) and an integer number (n). The function must return a string that has n repetitions of text. If n is non-positive this function must return the empty string.


Examples




  • repeat( "cow", 3 ) => "cowcowcow"

  • repeat( "alf", 10 ) => "alfalfalfalfalfalfalfalfalfalf"

  • repeat( "repeat", -3 ) => ""


a screenshot of it working would be amazing or an explenation how




Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here