This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 147
West Midlands Class 3 - Tom Rafferty - JavaScript Core 2 - Week 3 #107
Open
TomRafferty
wants to merge
9
commits into
CodeYourFuture:main
Choose a base branch
from
TomRafferty:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
896c5a6
exercise 1 completed
TomRafferty c9e7830
exercise 2 complete
TomRafferty cac03b5
1-alarm functional
TomRafferty 8d1696c
2-quote-generator
TomRafferty 6081f41
3-slideshow functional
TomRafferty 9b44940
DOM-practice finished
TomRafferty 178cfd6
completed quote generator extra task
TomRafferty 55fa127
quote generator finished with extra tasks
TomRafferty a6ed492
completed-ish extras
TomRafferty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,65 @@ const movies = [ | |
|
|
||
| // create showMovies function | ||
|
|
||
| //Task 1 version | ||
| // function showMovies(movieArray){ | ||
| // const allMoviesDiv = document.getElementById("all-movies"); | ||
| // const moviesNumberEl = document.getElementById("movies-number"); | ||
| // for(let movie in movieArray){ | ||
| // //create the <p> | ||
| // const pEl = document.createElement("p"); | ||
| // //add the text | ||
| // pEl.innerHTML = `Title: ${movieArray[movie].title}<br />Director: ${movieArray[movie].director}`; | ||
| // //append the <p> to the <div> | ||
| // allMoviesDiv.appendChild(pEl); | ||
| // //update the number | ||
| // moviesNumberEl.innerHTML = `${movieArray.length}` | ||
| // } | ||
| // } | ||
| // showMovies(movies); | ||
|
|
||
| //Task 2 version | ||
| function showMovies(movieArray){ | ||
| const allMoviesDiv = document.getElementById("all-movies"); | ||
| const moviesNumberEl = document.getElementById("movies-number"); | ||
| let count = 0; | ||
| //clear movies from DOM | ||
| for(let i = 0; i < allMoviesDiv.childNodes.length - 1; i++){ | ||
| //start at the end | ||
| allMoviesDiv.lastChild.remove() | ||
| } | ||
| function writeMoviePerSecond(){ | ||
| if(count < movieArray.length){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is the movieArray defined or did you mean to type movies.length? |
||
| //create the <p> | ||
| const pEl = document.createElement("p"); | ||
| //add the text | ||
| pEl.innerHTML = `Title: ${movieArray[count].title}<br />Director: ${movieArray[count].director}`; | ||
| //append the <p> to the <div> | ||
| allMoviesDiv.appendChild(pEl); | ||
| //update the number | ||
| moviesNumberEl.innerHTML = `${movieArray.length}`; | ||
| count++; | ||
| setTimeout(writeMoviePerSecond, 1000); | ||
| } | ||
| } | ||
| writeMoviePerSecond(); | ||
| } | ||
| showMovies(movies); | ||
|
|
||
| // create a new movie object for your favorite movie | ||
| const newMovie = { | ||
| title: "Snatch", | ||
| director: "Guy Ritchie", | ||
| type: "comedy", | ||
| haveWatched: true, | ||
| }; | ||
|
|
||
| // create addMovies function | ||
| function addMovies(movie){ | ||
| //add new movie after 2 seconds | ||
| setTimeout(movies.push(movie), 2000) | ||
| } | ||
| addMovies(newMovie); | ||
|
|
||
| //I may come back and finish the form extra task but for now | ||
| //I'm going to leave it at that | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,35 @@ | ||
| /** Write your CSS in here **/ | ||
| body{ | ||
| background-color: crimson; | ||
| } | ||
| #quoteBox{ | ||
| background-color: cornsilk; | ||
| padding: 8em; | ||
| margin: 5em; | ||
| margin-top: 1em; | ||
| margin-bottom: 0.5em; | ||
| border-bottom: solid; | ||
| border-color: gray; | ||
| border-width: 1em; | ||
| border-radius: 5em; | ||
| } | ||
| #quoteBox p{ | ||
| text-align: center; | ||
| font-size: 3em; | ||
| font-family:'Courier New', Courier, monospace; | ||
| } | ||
| #author{ | ||
| font-size: 2em; | ||
| color: grey; | ||
| margin-top: 1em; | ||
| } | ||
| button{ | ||
| padding: 1em; | ||
| margin-left: 80%; | ||
| border: none; | ||
| border-bottom: solid; | ||
| border-width: 0.1em; | ||
| border-radius: 0.5em; | ||
| border-color: brown; | ||
| background-color: salmon; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this loop do? the variable i is not used within the { }.