stairway
05-15-2009, 01:25 AM
I am trying both .split and .charCodeAt for the first time. When I put them into one test program it does not even give me the prompt I put into the program to serve as the input, just a blank white page. I wanted the program to tell me if the last letter of the first word is "e" or not, but anyways, here is the short bit of code i wrote for it:
<script language="text/javascript" type="text/javascript">
var input = prompt("Your text goes here","the cow says moo");
var lower = input.toLowerCase();
var words = lower.split(" ");
if (words[0].charCodeAt(-1); == "e") {
var statement = words[0] + "ends in 'e'";
}
document.write(statement);
</script>
<script language="text/javascript" type="text/javascript">
var input = prompt("Your text goes here","the cow says moo");
var lower = input.toLowerCase();
var words = lower.split(" ");
if (words[0].charCodeAt(-1); == "e") {
var statement = words[0] + "ends in 'e'";
}
document.write(statement);
</script>