With all the alerts to test if the code is right. My code is a little different of the solution, is more comprehensive, and a little more academic, maybe because wasn't try and error, but if the rule have meaning will work because I used the right sintax:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String making parts of parts</title>
</head>
<body>
<ul>
<caption><h2>Live output</h2></caption>
<li>MAN675847583748sjt567654;Manchester Piccadilly</li>
<li>GNF576746573fhdg4737dh;Greenfield</li>
<li>LIV5hd737456236dch46dg4;Liverpool Lime Street</li>
<li>SYB4f65hf75f75f736463;Stalybridge</li>
<li>HUD5767ghtyfyr4536dh45dg45dg3;Huddersfield</li>
</ul>
<script>
//alert(6);
const list = document.querySelector('ul'); // Test conflict
//alert(1);
list.innerHTML = '';
alert(2);
let stations = ['MAN675847583748sjt567654;Manchester Piccadilly', 'GNF576746573fhdg4737dh;Greenfield', 'LIV5hd737456236dch46dg4;Liverpool Lime Street', 'SYB4f65hf75f75f736463;Stalybridge', 'HUD5767ghtyfyr4536dh45dg45dg3;Huddersfield'];
for (let station of stations){
let letters3 = station.slice(0,3);
alert(letters3);
let semiCol = station.indexOf(';');
alert(semiCol);
let frase = letters3 +' : '+ station.slice(semiCol+1);
alert(frase);
// Write your code just below here
const result = station;
const listItem = document.createElement('li');
listItem.textContent = result;
list.appendChild(listItem);
}
</script>
</body>
</html>
Also the test of conflict that is written in the code above was that if continuous of the way was in the Mozilla will got in conflict with the 'list.innerHTML' so the code will be wrong right in the line above but the code is wrong in the line before but the console will accuse the mistake be in the second line, pri pri pri. Rute Bezerra de Menezes Gondim
No comments:
Post a Comment