Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add pull request #23

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
125 changes: 118 additions & 7 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,122 @@
'use strict';

'use strict';
{
const bookTitles = [
// Replace with your own book titles
'harry_potter_chamber_secrets',
];

// Replace with your own code
console.log(bookTitles);
const title = [

'harry_potter_chamber_secrets',

'alchemist', //Paulo coelho
'paula',
'orlando',
'divine-comedy',
'the-odyssey',
];

let objBooks = {

"harry_potter_chamber_secrets" :
{

title :"harry_potter_chamber_secrets",

language:"english",

author:"Joanne K. Rowling",

},

"alchemist":
{
title:"alchemist",

language:"english",

author:"paulo-coelho",

},

"paula":{

title:"paula",

language:"english",

author:"isabel allende",

},
"orlando":
{
title:"orlando",

language:"english",

author:"virgina wolf",

},
"divine-comedy" :
{

title:"divine-comedy",

language:"English",

author:"dante",

},

"the-odyssey":
{

title:"the-odyssey",

language: "english",

author:"homeros",

}



}



function listBooks() {

let i = 0;

let ul = document.createElement('ul')

for (i = 0; i < title.length; i++) {

let li = document.createElement('li');

li.textContent = title[i];

ul.appendChild(li);
}
}

document.body.appendChild(ul);
document.body.onload = listBooks;
const objBooksArr = [];
for (const newListBooks in objBooks) {
console.log(newListBooks);
objBooksArr.push(objBooks[newListBooks])

}



const bookPic = {

'harry_potter_chamber_secrets':potter.jpg ,
'alchemist':alchemist,
'paula' :paula.jpg,
'orlando':woolf.jpg,
'divine-comedy':divine.jpg,
'the-odyssey' :odyssy.jpg,
};


19 changes: 18 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
<!-- replace this with your HTML content -->
<!-- replace this with your HTML content -->
<!DOCTYPE html>

<html>

<head>

<title> Book Titles</title>
<script src="app.js"></script>

</head>
<body>

<div id="objBooksArr"></div>


</body>
</html>
3 changes: 2 additions & 1 deletion Week2/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
</head>
<body>
<h3>Here is your advice for the day:</h3>
<h1 id="advice"></h1>
<ul id="advice"></ul>
<button id="add-advice">add one more </button>
<script type="text/javascript" src="./lecture-exercises.js"></script>
</body>
</html>
36 changes: 34 additions & 2 deletions Week2/lecture-exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,41 @@ async function getRandomAdvice() {
return adviceData.slip.advice;
}

let allAdvice=[]
const adviceEl = document.getElementById('advice');


function updateDOM() {
adviceEl.innerHTML= '';

allAdvice.forEach((advice, index)=> {


const adviceItem=document.createElement ('li')
adviceEl.appendChild(adviceItem);
adviceItem.innerText=advice;

const removeButton =document.createElement('button')
removeButton.innerText='remove';
adviceItem.appendChild(removeButton);
removeButton.addEventListener('click',() => deleteAdvice(index));_
})
}
function deleteAdvice (index){
allAdvice.splice(index,1);
updateDOM();
}
function upcaseAllAdvice (){
allAdvice=allAdvice.map(advice => advice.toUpperCase());
updateDOM();

async function setRandomAdvice() {
const adviceEl = document.getElementById('advice');
adviceEl.innerText = await getRandomAdvice();
allAdvice.push (await getRandomAdvice());
updateDOM();
}

setRandomAdvice();

document.getElementById('add-advice').addEventListener('click', setRandomAdvice);

document.getElementById('upcase-everything').addEventListener('click', upcaseAllAdvice);