But, I have no idea for this, because I still didn't catch up what function should I used and where and when.
So, here is problem and script is below
Let the user type a word. Display the word in color, such that each letter's position in the alphaabet determines its color. Try using a string containing the alphabet and indexOf to find the position of each input letter.
** I have no idea what the heck is the indexOf function and how convert it thru word. So, please please solve this "simple" problem for you guys. Thank you.
colors = new Array; // "
var first=window.prompt("Please enter the "Hello world!"","");
var str="Hello world!";
var a = 'Hello world!';
document.writeln("<font size=+3>" + "<br>");
If this is a homework question then you should have been taught that, or at least be able to look it up in your textbook. You have heard of Google?
Originally Posted by gorush
In any case the alphabet string / indexOf idea is a poor solution.
Look up the string functions charAt(), charCodeAt(), toLowerCase().
Remember that arrays have a .length property.
Check out the % (remainder / modulus) operator: https://developer.mozilla.org/en/Jav...etic_Operators
You do know how to use prompt() ?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)