Spinal Tap Case infinite loop

Spinal Tap Case infinite loop
0.0 0

#1

Tell us what’s happening:
It keeps telling me that I have an infinite loop. I don’t see it. Any help would be appreciated.

Your code so far

function spinalCase(str) {
  var thing = str.split("");
  for ( i =1; i< thing.length; i++){
    for (j = 0; j< thing.length; j++){
    if ( thing[i] == thing[i].toUpperCase() && thing[j] != " "){
        thing.splice(thing[j], 0, " ");}}}
  var newThing= thing.join("");
newThing = newThing.replace(/[\s_]/g, "-"); 
  newThing= newThing.toLowerCase();
  return newThing; }
spinalCase('AllThe-small Things');

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Linux; Android 7.0; LGMP260 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36.

Link to the challenge:


#2

Inside the if after doing the splice try adding a console.log(thing); and have a look at the console when it runs, I believe that should answer your question :slight_smile: