Skip to content

Homework week1 #2

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ex app till 1.5
  • Loading branch information
annagabain committed Jul 5, 2019
commit 23a400b16eaf5ce160034cca705f43adc45cc360
14 changes: 14 additions & 0 deletions Week1/homework/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
3 changes: 3 additions & 0 deletions Week1/homework/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
137 changes: 123 additions & 14 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,136 @@
'use strict';

{
const favoriteGames = [
// Replace with your own book titles
const favoriteBooks = [
//1.1 Replace with your own book titles
'harry_potter_chamber_secrets',
'call_of_the_wild',
'the_turtle',
'snowball_and_the_bunny_adventures',
'chicken_little',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never played any of those games!
Need to look into it. Cool stuff 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;) good luck

'hey_friend',
'it_is_chilly_out_there',
'stone_and_pain',
'maybe_tomorrow',
'alise_in_wonderland',
];

// Replace with your own code
console.log(favoriteGames);
// document.body.onload = addElement;
// function displayGameTitles = () => {
// 1.2 Replace with your own code

let unorderedList = document.createElement("ul");
for (const gameIndex in favoriteGames) {
const listItem = document.createElement("li");
listItem.textContent = favoriteGames[gameIndex];
unorderedList.appendChild(listItem);
//console.log(favoriteBooks);

//1.3 Remove the temporary console.log from step 1.1. Make a function (or functions) that generate a ul with li elements for each book ID
// in the array using a for loop. Make sure that the function names you choose are an accurate reflection of what they do. As a reminder,
//here are the recommended Naming Conventions.

// // // function generateList(){
// // // let booksList = document.createElement('ul');
// // // booksList.setAttribute('id', 'li');
// // // document.body.appendChild(booksList);

// // // let index;
// // // for (index in favoriteBooks) {
// // // let booksListItem = document.createElement('li');
// // // booksList.appendChild(booksListItem);
// // // booksListItem.textContent = favoriteBooks[index];
// // // }
// // // }
// // // generateList();

// let unorderedList = document.createElement("ul");
// for (const gameIndex in favoriteBooks) {
// const listItem = document.createElement("li");
// listItem.textContent = favoriteBooks[gameIndex];
// unorderedList.appendChild(listItem);
// }

// // add the newly created element and its content into the DOM
// const currentDiv = document.getElementById("gameDiv");
// document.body.insertBefore(unorderedList, currentDiv);



// // 1.4 Make an object (not an array!) containing information for each book. Each property of this object should be another (i.e., nested)
// object with the book ID you thought up in step 1.1 as a key, and at least the following properties: title, language and author.
let bookProperties = {
harry_potter_chamber_secrets:{
title:"Harry Potter: Chamber of Secrets",
language:"English",
author:"Joanne K. Rowling",
},
call_of_the_wild:{
title:"Call of the Wild",
language:"English",
author:"Jack London",
},
the_turtle:{
title:"The Turtle",
language:"Anna -ish",
author:"Imaginery",
},
snowball_and_the_bunny_adventures:{
title:"Snowball and the Bunny Adventures",
language:"Anna -ish",
author:"Imaginery van Children",
},
chicken_little:{
title:"Chicken Little - The Sky is Falling",
language:"English",
author:"Folk Tale",
},
hey_friend:{
title:"Hey Friend",
language:"Anna -ish",
author:"Imaginery",
},
it_is_chilly_out_there:{
title:"It is Chilly out There",
language:"Anna -ish",
author:"Imaginery",
},
stone_and_pain:{
title:"Stone and Pain - The Life of Michelangelo Buonarotti",
language:"Chech",
author:"Karrel Schulz",
},
maybe_tomorrow:{
title:"Maybe Tomorrow",
language:"Anna -ish",
author:"Imaginery Delayer",
},
alise_in_wonderland:{
title:"Alise in Wonderland",
language:"English",
author:"Lewis Carrol",
}
}


// // 1.5 Now change the function from step 1.3 that you used to display the book ID's in a list to take the actual information about the book
// from the object and display that. Make sure you choose the correct HTML elements for each piece of info, for instance, a heading for the title.
function generateList(){
let booksList = document.createElement('ul');
booksList.setAttribute('id', 'li');
document.body.appendChild(booksList);

let index;

for (index in favoriteBooks) {
let booksListItem = document.createElement('li');
booksList.appendChild(booksListItem);

let BooksID = favoriteBooks[index];
booksListItem.textContent = favoriteBooks[index];
}
// add the newly created element and its content into the DOM
const currentDiv = document.getElementById("gameDiv");
document.body.insertBefore(unorderedList, currentDiv);
}
generateList();

// // 1.6 Beautify your html page with css (use the style.css file for that), add sources and alts to each of the images.

// // 1.7 Find and download book covers for each book and construct a new object which has as keys the book IDs again, and as value the path to
// the image source (e.g. { harry_potter_blabla: './img/harry_potter_blabla.jpg', ... }).

// // 1.8 Loop over these entries (hint: Object.keys(objectName) gives you an array containing the keys). Then write a function which places an
// image at the corresponding li element. Remember that objects are not ordered, so you cannot guarantee that the first key is the first li element.
// (Hint: you could give each li item an id tag by modifying the function you made before.)
}
22 changes: 20 additions & 2 deletions Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>

<!DOCTYPE html>
<html lang="en">
<head>
<title>FavoriteBooks Excercise</title>
</head>
<body>
<script src="app.js"></script>

</body>
</html>




<!-- <!DOCTYPE html>
<html lang="en">
<head>
<title>FavoriteBooks Excercise</title>
</head>
<body>
<script src="app.js"></script>
<div id = gameDiv></div>
<ul>

</ul>
</body>
</html>
</html> -->
1 change: 1 addition & 0 deletions Week2/placeholder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ggg
1 change: 1 addition & 0 deletions Week3/placeholder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ggg
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy