Weekly event manager code not working in javascript -


i have create weekly event manager in javascript . went wrong. code not working . please solve fault.whats wrong in ?????

var plan=prompt("hello , made week plan. type week name add event"); var week = ["saturday" , "sunday" , "monday" , "tuesday"]; var saturday; var sunday; var monday; var tuesday;  if( plan == "saturday" ) {  var saturday=prompt("what in saturday?");  } else if ( plan == "sunday") {  var sunday=prompt("what in sunday?");  } else if (plan == "monday") {  var monday=prompt("var getknow=prompt(""what in monday?");  } else if (plan == "tuesday" ) {  var tuesday=prompt("what in tuesday?");  }    var getknow=prompt("do want cheack schedule? type week name");   if ( getknow == saturday) {  alert(saturday);  } else if (getknow == sunday ) {  alert(sunday);  } else if (getknow == monday) {  alert(monday);   } else if (getknow == tuesday) {  alert(tuesday);  } 

everything working without theese lines of codes

var getknow=prompt("do want cheack schedule? type week name");  if ( getknow == saturday) {  alert(saturday);  } else if ( getknow == sunday ) {  alert(sunday);   } else if ( getknow == monday ) {  alert(monday);   } else if ( getknow == tuesday ) {  alert(tuesday);  } 

well had errors, keep learning , time won't make many mistakes. read comments below, check code out, should work fine.

i list errors below. first 1 was:

var monday=prompt("var getknow=prompt(""what in monday?"); 

then saw declared same variables twice, don't need do:

var sunday=prompt("what in sunday?"); var tuesday=prompt("what in tuesday?"); var sunday=prompt("what in sunday?"); 

later on comparing user's answer variable, should have been string:

    if ( getknow == saturday) {  alert(saturday);  } else if (getknow == sunday ) {  alert(sunday);  } else if (getknow == monday) {  alert(monday);   } else if (getknow == tuesday) {  alert(tuesday);  } 

this code should work:

var plan = prompt("hello , made week plan. type week name add event").tolowercase(),     week = ["saturday" , "sunday" , "monday" , "tuesday"],     saturday,     sunday,     monday,     tuesday;  if( plan === "saturday" ) {      saturday = prompt("what in saturday?");  }   else if ( plan === "sunday") {      sunday = prompt("what in sunday?");  }   else if (plan === "monday") {     //error var monday=prompt("var getknow=prompt(""what in monday?");     monday = prompt("what in monday?");  }   else if (plan === "tuesday" ) {      tuesday = prompt("what in tuesday?");  }    var getknow = prompt("do want cheack schedule? type week name");  // here, prompt sting not variable if ( getknow === "saturday") {  alert(saturday);  }   else if (getknow === "sunday" ) {  alert(sunday);  }   else if (getknow === "monday") {  alert(monday);   }   else if (getknow === "tuesday") {  alert(tuesday); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -