samedi 6 novembre 2021

Simple combination about looping and if statement [duplicate]

im newbie, a real newbie. I got stuck here. I hope u can help me. This code is what I`ve tried about challenge in beginner js book.

I expected that my code will eventually run and fill the output variable. There's no error messages.

var input="javascript is awesome"
y=input.length
var output="";

for(i=0;i<=y;i++){
  if(input[i]="a"){
    output[i]+="4";}

  else if(input[i]="i"){
      output[i]+="1";
    } 
    
  else if(input[i]="e"){
      output[i]+="3";
    }
  
  else if(input[i]="o"){
    output[i]+="0";
  } 
  
  else{
    output[i]+=input[i]
  }

  console.log(output);
  }

and it's always showed blank. I've tried so many times but I still stuck in here

Aucun commentaire:

Enregistrer un commentaire