Skip to content

Week3 #24

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 15 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
Co-authored-by: Gabe Rodriguez <grod220@gmail.com>
  • Loading branch information
Nouransaeed committed Aug 14, 2019
commit bb1baa6f6ed41ab70d97dc9e4d7d9afd36ee85a8
102 changes: 40 additions & 62 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,31 @@

'use strict';
{

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",

},
const titles = [
'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",
Expand Down Expand Up @@ -75,37 +56,34 @@
author:"homeros",

}



}

const ul = document.createElement('ul');

ul.setAttribute('id', 'booktitle');

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);
}
/* function listBooks() {
// let i = 0; // this is unnecessary
let ul = document.createElement('ul')
for (let i = 0; i < title.length; i++) {
let li = document.createElement('li');
li.textContent = title[i];
ul.appendChild(li);
}
// we don't do anything with the ul
// ???
}

document.body.appendChild(ul);
document.body.appendChild(ul); // where does ul come from? This will throw an error.
document.body.onload = listBooks;
Copy link

Choose a reason for hiding this comment

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

Yeah, Think you'll have to do Prettier for everything. See how the indentation is off here?

const objBooksArr = [];
for (const newListBooks in objBooks) {
console.log(newListBooks);
objBooksArr.push(objBooks[newListBooks])

}
}



Expand Down
21 changes: 7 additions & 14 deletions Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<!-- 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>
<head>
<title> Book Titles</title>
<script src="app.js"></script>
</head>
<body>
<div id="obj-books-Arr"></div>
</body>
</html>
Copy link

Choose a reason for hiding this comment

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

Strange spacing here too

31 changes: 17 additions & 14 deletions Week3/homework/step2-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@
function repeatStringNumTimesWithFor(str, num) {
let result = '';
for (let i = 0; i < num; i++) {
result += str;
result += str;
}
return result;
console.log('for', repeatStringNumTimesWithFor('abc', 3)),
}

console.log('for', repeatStringNumTimesWithFor('abc', 3))

//while loop
function repeatStringNumTimesWithWhile(str, num) {
let result = ''
let counter = 0;
while (counter < num) {
result += str;
counter++;
let result = ''
let counter = 0;
while (counter < num) {
result += str;
counter++;
}
return result;
return result;
}
console.log('while', repeatStringNumTimesWithWhile('abc', 3));
function repeatStringNumTimesWithDoWhile(str, num) {
let result = '';
let i = 0;
if (num > 0) {
do {
result += str,
do {
result += str;
i++;
} while (i < num);
}
return result;
}
console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 0)),
console.log('do-while', repeatStringNumTimesWithDoWhile('abc', 0));
module.exports = {
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile,
repeatStringNumTimesWithFor,
repeatStringNumTimesWithWhile,
repeatStringNumTimesWithDoWhile,
};
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