I was given a task to create un ordered list and li items from an array such that when clicked on the item it will print the text value in the console. So, here is my solution.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <div id="abcd">Hello</div>
             let entry = document.querySelector("#abcd")
             let ulitem = document.createElement("ul")
             const arr = ['a', 'b', 'c', 'd']
             arr.forEach(i => {
                 const li = document.createElement("li")
                 li.innerHTML = i
                 li.addEventListener('click', (event) => {

Leave a Reply

Your email address will not be published. Required fields are marked *