Hi, I’m trying to make a script for class, but I spend over 10 hours, but I still didn’t make it yet. So, would you give some help for me? It probably a basic script for you guys. Thank you.
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.
var first=window.prompt(“Please enter the “Hello world.””,“”);
var i=0;
var count=0;
var b=“d”;
document.writeln(“<font size=+3>” + “<br>”);
var str=“Hello world”
document.write(str.indexOf(“d”)+“<br />”);
document.write(str.indexOf(“United”) + “<br />”);
document.write(str.indexOf(“united”));
for(i=0;i<str.length;i++)
{
document.writeln(“<font color=”+colors[i]+“>”+ i “</font>” longdays[i].fontcolor(colors[i]) + “<br>”);
document.write(count );
document.writeln(“<hr>”);
document.writeln(“<br>”);
//–>
</script>
</head>
<body>
<font size=+2>
The preceding text was generated entirely by JavaScript code in this page.
<br>
</font>
</body>
</html>