Tuesday, May 24, 2022

All the tests, in the test phase

 Another snippet of JS code

with all the tests to confirm if the code is validy, so is there all the alerts I put to test the coding:

<!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>Exercise with strings</title>
</head>
<body>


    <ul>
        <caption><h2>Live output</h2></caption>
            <li>lonDon</li>
            <li>ManCHESTer</li>
            <li>BiRmiNGHAM</li>
            <li>liVERpoOL</li>
    </ul>

    <script>
        const list = document.querySelector('ul');
        list.innerHTML = ' ';
        const cities = ['lonDon', 'ManCHESTer','BiRmiNGHAM','liVERpoOL']

        for (let city of cities) {
            // Write your code just below here
            alert(city);
            const resultIn = city.toLocaleLowerCase();
            alert(resultIn);
            let capital = city.toUpperCase();
            capital = capital[0];
            alert(capital);

            let resultIni = resultIn.replace(resultIn[0],capital);
            alert(resultIni);
            const result = city;
            const listItem = document.createElement('li');
            listItem.textContent = result;
            list.appendChild(listItem);
        }
    </script>

</body>

</html>

Rute Bezerra de Menezes Gondim




No comments:

Post a Comment