We would like to know how to return a string from a function.
<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
<!-- w ww .j av a 2s .c o m-->
function getState(abbr){
if (abbr=="WY")
{
return "Wyoming";
}
}
var stateName = getState("WY");
document.writeln(stateName);
</script>
</body>
</html>
The code above is rendered as follows: