Hello, please give me the code for this assignment in JAVASCRIPT as well as a HT
ID: 3722076 • Letter: H
Question
Hello, please give me the code for this assignment in JAVASCRIPT as well as a HTML page to show it, thank you (this assignment covers Strings in javascript), thanks for the help
Assignment Assignment (H.M.S. Stringsarefore): Admiral Captain Corcoran has been given a fleet of a dozen new pirate chasing ships which the queen her majesty wishes to name after her significant other (spouse /pet / other), but she cannot give every ship the same name. Create a program which accepts the name of her significant other and uses that name to derive different 12 ship names through JavaScript string operations. (use charAt, indexOf, substring, trim, replace, toUpperCase, toLowerCase) Store the names into an array and write them to the page as a list. Make sure the names put fear into the heart of every pirate! Important Procedures for All Labs. Here are some general notes for perfection that you should follow for every assignment: 1 Please produce all web content to HTMIL S standardsExplanation / Answer
Replace ship names by your own
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<h1>Ships</h1>
<ul id="ships">
</ul>
</body>
<script type="text/javascript">
var ship1 = "Ship1";
var ship2 = "Ship2";
var ship3 = "Ship3";
var ship4 = "Ship4";
var ship5 = "Ship5";
var ship6 = "Ship6";
var ship7 = "Ship7";
var ship8 = "Ship8";
var ship9 = "Ship9";
var ship10 = "Ship10";
var ship11 = "Ship11";
var ship12 = "Ship12";
var ships = [];
ships.push(ship1);
ships.push(ship2);
ships.push(ship3);
ships.push(ship4);
ships.push(ship5);
ships.push(ship6);
ships.push(ship7);
ships.push(ship8);
ships.push(ship9);
ships.push(ship10);
ships.push(ship11);
ships.push(ship12);
str = "";
for (i = 0; i < ships.length; i++) {
str += "<li>Ship" + (i + 1) + ": " + ships[i] + ", <br /><b>charAt - at pos 2 is </b>" + ships[i].charAt(2) + "<b>indexOf - hi is</b>" + ships[i].indexOf("hi") + ", <br /><b>substring of 0,2 is </b>" + ships[i].substring(0, 2) + ", <br /><b>trim is </b>" + ships[i].trim() + ", <br /><b>replace of hip into HIP is </b>" + ships[i].replace("hip", "HIP") + ", <br /><b>toUpperCase: </b>" + ships[i].toUpperCase() + ", <br /><b>toLowerCase </b>" + ships[i].toLowerCase() + "<br /><br /></li>";
}
document.getElementById("ships").innerHTML = str;
</script>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.