Tuesday, May 24, 2022

The final result of the code

 Without all the alerts of the tests working how supposes to be:

<!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
           
            const resultIn = city.toLocaleLowerCase();
           
            let capital = city.toUpperCase();
            capital = capital[0];
           
            let resultIni = resultIn.replace(resultIn[0],capital);
           
            const result = resultIni;
            const listItem = document.createElement('li');
            listItem.textContent = result;
            list.appendChild(listItem);
        }
    </script>

</body>

</html>

Rute Bezerra de Menezes Gondim




No comments:

Post a Comment