1// Function: creates a new paragraph and appends it to the bottom of the HTML body.
2
3function createParagraph() {
4 let para = document.createElement('p');
5 para.textContent = 'You clicked the button!';
6 document.body.appendChild(para);
7}
8
9/*
10 1. Get references to all the buttons on the page in an array format.
11 2. Loop through all the buttons and add a click event listener to each one.
12
13 When any button is pressed, the createParagraph() function will be run.
14*/
15
16const buttons = document.querySelectorAll('button');
17
18for (let i = 0; i < buttons.length ; i++) {
19 buttons[i].addEventListener('click', createParagraph);
20}
1JS is th short form of Javascript.
2It is used to make a website functionable.It is the heart of a website!
3 Javascript contains many functions like:
4◻ document.getElementById(id).innerHTML = a new html text
1Javascript is object oriented programing language.Javascript is both side clent side server side
2