Cats and Dogs explainer

The aim of this puzzle: Use JavaScript to create a button and add it to a webpage.

Walkthrough of the solution:
In this puzzle, you’ll use the createElement method, the textContent property, and the appendChild method to create a button and add it to the document body.

To complete the puzzle, create a variable called dogButton that stores a new button element using document.createElement('button'). Then, set the .textContent of dogButton to a string. Finally, append the dogButton element to the body.

To complete the puzzle, create a variable
Sample code solution:
(Tap below to reveal)

JavaScript

let title = document.createElement('h1');
title.textContent = 'Cuteness';

let catImg = document.createElement('img');
catImg.src =  '../../static/images/greyTabby.jpg';

let catButton = document.createElement('button');
catButton.textContent = 'Click Here!';

let dogImg = document.createElement('img');
dogImg.src = '../../static/images/couchDog.jpg';

let dogButton = document.createElement('button');
dogButton.textContent = 'Or Here!';

document.body.appendChild(title);
document.body.appendChild(catImg);
document.body.appendChild(catButton);
document.body.appendChild(dogImg);
document.body.appendChild(dogButton);

HTML Concepts: <h1>, <img>, <button>
JavaScript Concepts: .textContent, .createElement(), document body, .appendChild(), Variables