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

Source: JavaSript – Stack Overflow

November 7, 2021
Category : News
Tags: for-loop | if-statement | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.