what is javascript
/*
JavaScript, often abbreviated as JS,
is an interpreted programming language that
conforms to the ECMAScript specification.
JavaScript is high-level, often just-in-time compiled,
and multi-paradigm.
It has curly-bracket syntax,
dynamic typing, prototype-based object-orientation, and
first-class functions
reference:https://en.wikipedia.org/wiki/JavaScript
*/javascript is a programming language by javascript you can make websites, apps etc.. JavaScript gives web pages interactive elements that engage a user.// Function: creates a new paragraph and appends it to the bottom of the HTML body.
function createParagraph() {
let para = document.createElement('p');
para.textContent = 'You clicked the button!';
document.body.appendChild(para);
}
/*
1. Get references to all the buttons on the page in an array format.
2. Loop through all the buttons and add a click event listener to each one.
When any button is pressed, the createParagraph() function will be run.
*/
const buttons = document.querySelectorAll('button');
for (let i = 0; i < buttons.length ; i++) {
buttons[i].addEventListener('click', createParagraph);
}