Javascript examples for String Operation:String Compare
if statement to compare string value with number
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w w w . j a v a2 s . c o m var inventory = "10"; if( inventory == "Sold Out" ){ document.write("<b>Sold Out</b>"); }else if( inventory >= 6 ){ document.write("<b>more than 5</b>"); }else if( inventory <= 5 ){ document.write("<b>running low</b>"); }else{ document.write("<b>error</b>"); } }); </script> </head> <body> </body> </html>