Having Trouble with Error Message

Link to coding challenge. Training on Mumbling | Codewars

The logic is this — every time you loop, it will repeat the string.

I’ve done good so far at breaking down the problem. I am receiving this error when trying to test it (note: clicking “test” is broken and is a known issue with this Kata. Hit “submit” to see what I mean :smiley: )

  console.log(s);
	const split = s.split("");
  console.log(split);
  
  let myString = "";
  
  for (let i = 0; i < split.length; i++) {
    let result = split[i].repeat(i + 1);
    myString.push(result)
  }
}

TypeError: myString.push is not a function
    at accum (test.js:11:14)
    at Context.<anonymous> (test.js:20:20)
    at processImmediate (internal/timers.js:464:21)

Is it because it’s not an array? :stuck_out_tongue:

Use + or += to concatenate one string to another:

   let str = 'Every statement need a period';
   console.log(str);
   str += '.';
   console.log(str);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.