Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Co-Authored by: #388

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// query selector variables go here 👇

var randomPosterButton = document.querySelector(".show-random");
var image = document.querySelector(".poster-img");
var title = document.querySelector(".poster-title");
var quote = document.querySelector(".poster-quote");
// we've provided you with some data to work with 👇
var images = [
"./assets/bees.jpg",
Expand Down Expand Up @@ -99,9 +102,11 @@ var quotes = [
"A champion is defined not by their wins but by how they can recover when they fall."
];
var savedPosters = [];
var currentPoster;
var currentPoster = document.querySelector(".poster");

// event listeners go here 👇
randomPosterButton.addEventListener('click', createRandomPoster);
addEventListener("load", createRandomPoster);

// functions and event handlers go here 👇
// (we've provided two to get you started)!
Expand All @@ -110,9 +115,19 @@ function getRandomIndex(array) {
}

function createPoster(imageURL, title, quote) {
return {
var poster = {
id: Date.now(),
imageURL: imageURL,
title: title,
quote: quote}
quote: quote
}
return poster
}

function createRandomPoster(){
newPoster = createPoster(images[getRandomIndex(images)], titles[getRandomIndex(titles)], quotes[getRandomIndex(quotes)]);
currentPoster.innerHTML =
`<img class="poster-img" src="${newPoster.imageURL}" alt="nothin' to see here">
<h1 class="poster-title">"${newPoster.title}"</h1>
<h3 class="poster-quote">"${newPoster.quote}"</h3>`
}