Skip to content
Prev Previous commit
Next Next commit
Changes Week1 and Week2
  • Loading branch information
Radhikajram committed Jul 7, 2019
commit 23784be4f8f97909d5690719e267d12d3c451bec
32 changes: 30 additions & 2 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const bookTitles = [

// Create ul element and assign id

const ul = document.createElement('ol');
const ul = document.createElement('ul');
ul.setAttribute('id', 'booktitle');

// eslint-disable-next-line no-unused-vars
function createBookList(bookId) {
Expand Down Expand Up @@ -111,7 +112,7 @@ function createBookListUsingObject(bookObj) {
li.appendChild(head);
li.appendChild(headLanguageContent);
li.appendChild(headAuthor);
document.write('<br>');
li.style.cssFloat = 'left';

ul.appendChild(li);

Expand Down Expand Up @@ -149,3 +150,30 @@ function imageDisplay(imageObject) {
}

imageDisplay(bookimage);

// eslint-disable-next-line no-undef
ul.style.display = 'grid';
ul.style.gridTemplateColumns = 'auto auto';
ul.style.gridAutoColumns = 'minmax(auto,auto)';
ul.style.gridAutoRows = 'minmax(auto,auto)';

// eslint-disable-next-line no-unused-vars
function createGrid(x) {
for (let rows = 0; rows < x; rows++) {
for (let col = 0; col < x; col++) {
// eslint-disable-next-line no-undef
// $('#booktitle').append("<div> class='grid'></div>");
const grid = document.getElementById("booktitle");
grid.appendChild(li)
}
}

// eslint-disable-next-line no-undef
$('.grid').height(960 / x);
// eslint-disable-next-line no-undef
$('.grid').width(960 / x);
}

// eslint-disable-next-line no-undef
createGrid(2);
*/
17 changes: 13 additions & 4 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ const tuesday = [
const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
}
const computeEarnings = maartjesTasks
.map(tasks => [tasks.duration] / 60)
.filter(duration => [duration] >= 2)
.map(duration => duration * maartjesHourlyRate)
.reduce((prev, curr) => [+prev + +curr])
.map(amount => '€' + amount.toFixed(2));

console.log(computeEarnings);

// /function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
// console.log(tasks, hourlyRate);
// }

// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
Expand Down
22 changes: 16 additions & 6 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
'use strict';

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

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));

/* function doubleOddNumbers(numbers) {
// // Replace this comment and the next line with your code
const newNumbers = [];
for (let i = 0; i < numbers.length; i++) {
if (numbers[i] % 2 !== 0) {
newNumbers.push(numbers[i] * 2);
}
}
return newNumbers;
} */

const doubleOddNumbers = myNumbers.filter(numbers => numbers % 2 !== 0).map(numbers => numbers * 2);
// eslint-disable-next-line no-unused-vars
const result = doubleOddNumbers(myNumbers);
console.log(result);

// Do not change or remove anything below this line
module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion Week2/test/map-filter.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { myNumbers, doubleOddNumbers } = require(`../homework/map-filter`);
const { myNumbers, doubleOddNumbers } = require(`../homework/map-filter`).default;

describe('map_filter', () => {
test('result -> [2, 6]', () => {
Expand Down
Loading