Char Method javascript -
having issues... can tell me did wrong on javascript code:
function getname() { var the_name = window.prompt("enter first name", ""); var first_char = the_name.charat(0); if(first_char = "s") { document.write(the_name); } else { window.alert("please enter name starts uppercase s have displayed."); } }
then not valid syntax, , use == on string compare
function getname() { var the_name=window.prompt("enter first name",""); var first_char = the_name.charat(0); if(first_char== "s") { document.write(the_name); } else { window.alert("please enter name starts uppercase s have displayed."); } }
Comments
Post a Comment