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

Skip to content

update #17

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 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
Empty file added Week1/elia.js
Empty file.
Binary file added Week1/homework/Little.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 88 additions & 7 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,92 @@
// assert = chai.assert.deepEqual

'use strict';
/*//make an array

const bookList = [
'the-kite-runner',
'number-the-stars',
'pride-and-prejudice',
'the-outsiders',
'little-women',
];
//this is how I printed my array in the DOM but not like a list. like a line!
document.querySelector('#myArr').innerHTML = `My bookList Array : ${bookList}`

//Now I want to creat an unordered list out of the bookList array

function createList() {
let uList = document.createElement('ul');
uList.setAttribute('id', 'li');
document.body.appendChild(uList);


for (let index in bookList) {
let eachBook = document.createElement('li');
uList.appendChild(eachBook);

eachBook.textContent = bookList[index];
}
}
createList();*/

{
const bookTitles = [
// Replace with your own book titles
'harry_potter_chamber_secrets',
];
//Now I have an object array of my must read books information



let books = [
{
title: 'The Kite Runner',
author: 'Khaled Hosseini',
language: 'English',
cover: 'kite.jpg'
},
{
title: 'Number the Stars',
author: 'lois Lowry',
language: 'English',
cover: 'number.jpg'

},
{
title: 'Pride and Prejudice',
author: 'Jane Austen',
language: 'English',
cover: 'pride.jpg'
},
{
title: 'The Outsiders',
author: 'S.E Hinton',
language: 'English',
cover: 'outsiders.jpeg'

},
{
title: 'Little Women',
author: 'Louisa May',
language: 'English',
cover: 'Little.png'
}
]

document.body.onload = printBooks;
//now I want to print all the information in the DOM.

function createAndAppend(typ, parent, attributes = {}) {
const elem = document.createElement(typ);
parent.appendChild(elem);
for (const key in attributes) elem[key] = attributes[key]
return elem
}

// Replace with your own code
console.log(bookTitles);
function printBooks() {
const h1 = createAndAppend('h1', document.body, { innerText: 'My Must Read Books' });
const ul = createAndAppend('ul', document.body);
for (const book of books) {
const li = createAndAppend('li', ul);
const h2 = createAndAppend('h2', li, { innerText: book.title });
const author = createAndAppend('h4', li, { innerText: `Author: ${book.author}` })
const language = createAndAppend('h4', li, { innerText: `Language: ${book.language}` })
const img = createAndAppend('img', li, { src: book.cover, height: 350, width: 250 })
}
}
15 changes: 14 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>
<html>

<head>
<title>Elia Books</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<script src="app.js">
</script>
</body>

</html>
Binary file added Week1/homework/kite.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/number.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/outsiders.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/pride.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion Week1/homework/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
/* add your styling here */
/* add your styling here */
body {
background-color:rgba(55, 42, 42, 1) ;
margin: 12px;
padding: 12px;

}

li {
background-color: rgba(114, 49, 49, 1);
color: white;
border-style: solid;
padding: 20px;
}
h1 {
color: white;
text-align: center;
}
38 changes: 20 additions & 18 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const monday = [
{
const monday = [{
name: 'Write a summary HTML/CSS',
duration: 180,
},
Expand All @@ -19,8 +18,7 @@ const monday = [
},
];

const tuesday = [
{
const tuesday = [{
name: 'Keep writing summary',
duration: 240,
},
Expand All @@ -42,24 +40,28 @@ const tuesday = [
},
];

const maartjesTasks = monday.concat(tuesday);
const tasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate)


function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
}
const taskHours = tasks.map(hours => tasks.duration / 60).filter(hours => hours <= 2);
const euroRates = taskHours.map(hours => hours * maartjesHourlyRate);




// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);

// add code to convert `earnings` to a string rounded to two decimals (euro cents)
// add code to convert `earnings` to a string rounded to two decimals (euro cents)

console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);

// Do not change or remove anything below this line
module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings,
};
// Do not change or remove anything below this line
module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings,
};
16 changes: 11 additions & 5 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
}

const myNumbers = [1, 2, 3, 4];

const doubleOddNumbers = numbers => {
const odds = numbers.filter(function(number) {
return number % 2 !== 0;
});
const doubles = odds.map(function(number) {
return number * 2;
});
return doubles;
};

console.log(doubleOddNumbers(myNumbers));

// Do not change or remove anything below this line
Expand Down
14 changes: 14 additions & 0 deletions Week2/homework/squirtle-sprites.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="squirtle-sprites.css">
</head>


<body>

<script src="squirtle-sprites.js"></script>
</body>

</html>
26 changes: 25 additions & 1 deletion Week2/homework/squirtle-sprites.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@
Call this function to get a JSON string of the data
(simulates calling a server to retrieve data)
*/
function createAndAppend(typ, parent, attributes = {}) {
const elem = document.createElement(typ);
parent.appendChild(elem);
for (const key in attributes) elem[key] = attributes[key]
return elem
}
function fetchPokemonData() {
return '{"abilities":[{"ability":{"name":"rain-dish","url":"https://pokeapi.co/api/v2/ability/44/"},"is_hidden":true,"slot":3},{"ability":{"name":"torrent","url":"https://pokeapi.co/api/v2/ability/67/"},"is_hidden":false,"slot":1}],"base_experience":63,"forms":[{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-form/7/"}],"height":5,"held_items":[],"id":7,"is_default":true,"location_area_encounters":"https://pokeapi.co/api/v2/pokemon/7/encounters","name":"squirtle","order":10,"species":{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-species/7/"},"sprites":{"back_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png","back_female":null,"back_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png","back_shiny_female":null,"front_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png","front_female":null,"front_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png","front_shiny_female":null},"stats":[{"base_stat":43,"effort":0,"stat":{"name":"speed","url":"https://pokeapi.co/api/v2/stat/6/"}},{"base_stat":64,"effort":0,"stat":{"name":"special-defense","url":"https://pokeapi.co/api/v2/stat/5/"}},{"base_stat":50,"effort":0,"stat":{"name":"special-attack","url":"https://pokeapi.co/api/v2/stat/4/"}},{"base_stat":65,"effort":1,"stat":{"name":"defense","url":"https://pokeapi.co/api/v2/stat/3/"}},{"base_stat":48,"effort":0,"stat":{"name":"attack","url":"https://pokeapi.co/api/v2/stat/2/"}},{"base_stat":44,"effort":0,"stat":{"name":"hp","url":"https://pokeapi.co/api/v2/stat/1/"}}],"types":[{"slot":1,"type":{"name":"water","url":"https://pokeapi.co/api/v2/type/11/"}}],"weight":90}';
let info = '{"abilities":[{"ability":{"name":"rain-dish","url":"https://pokeapi.co/api/v2/ability/44/"},"is_hidden":true,"slot":3},{"ability":{"name":"torrent","url":"https://pokeapi.co/api/v2/ability/67/"},"is_hidden":false,"slot":1}],"base_experience":63,"forms":[{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-form/7/"}],"height":5,"held_items":[],"id":7,"is_default":true,"location_area_encounters":"https://pokeapi.co/api/v2/pokemon/7/encounters","name":"squirtle","order":10,"species":{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-species/7/"},"sprites":{"back_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png","back_female":null,"back_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png","back_shiny_female":null,"front_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png","front_female":null,"front_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png","front_shiny_female":null},"stats":[{"base_stat":43,"effort":0,"stat":{"name":"speed","url":"https://pokeapi.co/api/v2/stat/6/"}},{"base_stat":64,"effort":0,"stat":{"name":"special-defense","url":"https://pokeapi.co/api/v2/stat/5/"}},{"base_stat":50,"effort":0,"stat":{"name":"special-attack","url":"https://pokeapi.co/api/v2/stat/4/"}},{"base_stat":65,"effort":1,"stat":{"name":"defense","url":"https://pokeapi.co/api/v2/stat/3/"}},{"base_stat":48,"effort":0,"stat":{"name":"attack","url":"https://pokeapi.co/api/v2/stat/2/"}},{"base_stat":44,"effort":0,"stat":{"name":"hp","url":"https://pokeapi.co/api/v2/stat/1/"}}],"types":[{"slot":1,"type":{"name":"water","url":"https://pokeapi.co/api/v2/type/11/"}}],"weight":90}';
//console.log(info);
let infoParsed = JSON.parse(info);
//console.log(infoParsed);
let images = infoParsed.sprites;
for (let image in images) {

if (images[image]) {
//createAndAppend('img', document.body, src = "images[i]");
let img = document.createElement('img');
img.src = images[image];
document.body.appendChild(img);
}


}

}


/* Code goes below */
fetchPokemonData();
10 changes: 5 additions & 5 deletions Week3/homework/step2-1.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use strict';

function foo(func) {
// What to do here?
// Replace this comment and the next line with your code
console.log(func);
function foo() {

console.log('Week3');
}

function bar() {
Expand All @@ -12,5 +11,6 @@ function bar() {

foo(bar);


// Do not change or remove anything below this line
module.exports = foo;
module.exports = foo;
28 changes: 19 additions & 9 deletions Week3/homework/step2-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@

function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
const numbers = [];

// Replace this comment and the next line with your code
console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers);
for (let i = startIndex; i <= stopIndex; i++) {
numbers.push(i);
if (i % 3 === 0) {
threeCallback();
}
if (i % 5 === 0) {
fiveCallback();
}
if (i % 3 === 0 && i % 5 === 0) {
threeCallback(fiveCallback());
}
}
}


function sayThree(number) {
// Replace this comment and the next line with your code
console.log(number);
}
console.log('${number} is divisible by three')

};

function sayFive(number) {
// Replace this comment and the next line with your code
console.log(number);

console.log('${number} is divisible by five');
}

threeFive(10, 15, sayThree, sayFive);

// Do not change or remove anything below this line
module.exports = threeFive;
module.exports = threeFive;
23 changes: 16 additions & 7 deletions Week3/homework/step2-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ function repeatStringNumTimesWithFor(str, num) {
// eslint-disable-next-line prefer-const
let result = '';

// Replace this comment and the next line with your code
console.log(str, num, result);
for (let i = 0; i < num; i++) {
result = +str;
num--;
}

return result;
}

// but when I console.log it returns : for NaN!!!!
console.log('for', repeatStringNumTimesWithFor('abc', 3));

/*************************************************************************/

// Use a 'while' loop
function repeatStringNumTimesWithWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';

// Replace this comment and the next line with your code
console.log(str, num, result);
while (num > 0) {
result += str;
num--;
}

return result;
}
Expand All @@ -30,9 +36,12 @@ console.log('while', repeatStringNumTimesWithWhile('abc', 3));
function repeatStringNumTimesWithDoWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';
let i = 0;

// Replace this comment and the next line with your code
console.log(str, num, result);
do {
result = +str;
i++;
} while (i < num);

return result;
}
Expand Down
Loading