If statement instead of ternary operator


function spinalCase(str) {
  let aaa = str.toLowerCase();
  let bbb = ""
  for(let i=0; i<aaa.length; i++) {
  //bbb += aaa[i] === " " ? "-" : aaa[i]
  if(aaa[i] === " "){ 
    aaa[i]=== "-"
  }
  bbb += aaa[i]
  }
  console.log(bbb);
}

spinalCase('This Is Spinal Tap');

Hello:)
I try to rewrite the ternary operator into if statement. For some reason it is not working. What am I missing?

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