Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
556faa9
Update index.js
ebruispir Jul 9, 2019
7b766b7
Update app.js
ebruispir Jul 13, 2019
1be02fb
Update style.css
ebruispir Jul 13, 2019
85c7757
Add files via upload
ebruispir Jul 13, 2019
844fa46
Update index.html
ebruispir Jul 13, 2019
23e06b3
Update app.js
ebruispir Jul 13, 2019
c52e5c2
Update app.js
ebruispir Jul 13, 2019
00f5b80
Update app.js
ebruispir Jul 13, 2019
294b459
Update index.html
ebruispir Jul 13, 2019
b953e01
Update style.css
ebruispir Jul 13, 2019
294c287
Create arrayExercise.js
ebruispir Jul 16, 2019
ab61391
Create index.html
ebruispir Jul 16, 2019
d1b651b
Update index.html
ebruispir Jul 16, 2019
18ce1fb
Update index.html
ebruispir Jul 16, 2019
588bae5
Create jsonExercise.js
ebruispir Jul 17, 2019
dda88dd
Update index.html
ebruispir Jul 17, 2019
37d8dbb
Update map-filter.js
ebruispir Jul 17, 2019
1ce1998
Update maartjes-work.js
ebruispir Jul 19, 2019
61162bc
Update index.js
ebruispir Jul 23, 2019
12ecfaa
Update app.js
ebruispir Jul 23, 2019
fa5374e
Delete Metamorphosis.jpg
ebruispir Jul 23, 2019
b0f2f6d
Delete a_clockwork_orange.jpg
ebruispir Jul 23, 2019
59135b6
Delete animalfarm.jpg
ebruispir Jul 23, 2019
7c57b42
Delete crime_and_punishment.jpg
ebruispir Jul 23, 2019
a405866
Delete les_miserables.jpg
ebruispir Jul 23, 2019
3208e1c
Delete madonna_in_a_fur_coat.jpg
ebruispir Jul 23, 2019
4952de2
Delete notes_from_underground.jpg
ebruispir Jul 23, 2019
3e0eea5
Delete our_grand_despair.jpg
ebruispir Jul 23, 2019
e808623
Delete the_call_of_the_wild.jpg
ebruispir Jul 23, 2019
20a1493
Delete the_nightingale.jpg
ebruispir Jul 23, 2019
df92f8e
Update index.html
ebruispir Jul 23, 2019
a5a05fb
Update style.css
ebruispir Jul 23, 2019
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
2 changes: 1 addition & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- replace this with your HTML content -->
<!-- replace this with your HTML content -->
2 changes: 1 addition & 1 deletion Week1/homework/style.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* add your styling here */
/* add your styling here */
91 changes: 91 additions & 0 deletions Week2/exercises/arrayExercise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
'use strict';

/*Write a Javascript function to get first element of an array.
Passing a parameter 'n' will return the fist 'n' elements of the array.*/

const numbers = [' one ', ' two ', ' three ', ' four ', ' five '];
document.getElementById('array').innerHTML = 'Array :' + numbers;

function getFirstElement(array, index) {
const newArray = array.slice(0, index);
return newArray;
}

function callFistElement() {
document.getElementById('exe-1').innerHTML = getFirstElement(numbers, 3);
}

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

/* Write a Javascript program which accept a number as input an insert dashes (-) between
each two even numbers.For example if you accept 025468 the output should be 0-254-6-8. */

function dashInsert(str) {
var arrayNumbers = str.split('');
var newString = '';
for (var i = 0; i < arrayNumbers.length; i++) {
if (arrayNumbers[i] % 2 === 0 && arrayNumbers[i + 1] % 2 === 0) {
newString = newString + arrayNumbers[i] + '-';
} else {
newString = newString + arrayNumbers[i];
}
}
return newString;
}
function callDashInsert() {
const inputValue = document.querySelector('input').value;
document.getElementById('exe-2').innerHTML = dashInsert(inputValue);
}

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

/* write a Javascript program to find the most frequent item of an array.*/

const animals = [' cat ', ' dog ', ' bird ', ' lion ', ' cat ', ' dog ', ' cat '];
document.getElementById('animals').innerHTML = 'Array :' + animals;

function mostFrequentItem(array) {
var result = array[0];
var compare = 0;
for (var i = 0; i < array.length; i++) {
var count = 0;
for (var j = 0; j < array.length; j++) {
if (array[i] === array[j]) {
count++;
}
}
if (count > compare) {
compare = count;
result = array[i];
}
}
return result;
}

function callFrequentItem() {
document.getElementById('exe-3').innerHTML = mostFrequentItem(animals);
}

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

/* write a Javascript program which accept a string as input and swap the case of each
character.For example if you input 'The Quick Brown Fox' the output should be
'tHE qUICK bROWN fOX' .*/

function caseAlter(txt) {
var output = '';

for (var i = 0; i < txt.length; i++) {
if (txt[i] == txt[i].toUpperCase()) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

does this work? Should be tripple equals I think

output += txt[i].toLowerCase();
} else {
output += txt[i].toUpperCase();
}
}

return output;
}
function callCaseAlter() {
const input = document.getElementById('case-alter').value;
document.getElementById('exe-4').innerHTML = caseAlter(input);
}
29 changes: 29 additions & 0 deletions Week2/exercises/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>week2 exercise1</title>
</head>
<body>
<h2>Exercise-1</h2>
<p id="array"></p>
<button onclick="callFistElement()">Result :</button>
<p id="exe-1"></p>
<h2>Exercise-2</h2>
<input type="text" value="Please enter numbers" />
<p id="exe-2"></p>
<button onclick="callDashInsert()">Insert Dashes</button>
<h2>Exercise-3</h2>
<p id="animals"></p>
<button onclick="callFrequentItem()">Result :</button>
<p id="exe-3"></p>
<h1>Exercise-4</h1>
<input id="case-alter" type="text" /><br /><br />
<button onclick="callCaseAlter() ">Result :</button>
<p id="exe-4"></p>
<script src="arrayExercise.js"></script>
<script src="jsonExercise.js"></script>
</body>
</html>
40 changes: 40 additions & 0 deletions Week2/exercises/jsonExercise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//Write a JavaScript program to get the length of an JavaScript object.

var object;
object = {
"Country": "Belgium",
"Capital": "Brussels",
"Language": "French-Dutch",
};

var getTheObjLength = key => {
return Object.keys(key).length;
};

console.log(getTheObjLength(object));


//Write a JavaScript function to check if an object contains given property.

var checkHaskey = (obj, key) => {
if (obj.hasOwnProperty(key)) {
console.log("Yes, I have " + key);
} else {
console.log("I have not " + key + " property");
}

};
console.log(checkHaskey(object, "Capital"));


//Write a JavaScript program to create a Clock. Console, every second :”14:37:42”,”14:37:43", “14:37:44”, "14:37:45"


function myClock() {
var today = new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
console.log(hours + ":" + minutes + ":" + seconds);
};
setInterval(myClock, 1000);
14 changes: 9 additions & 5 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ 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 taskDurations = tasks
.map(task => task.duration / 60)
.filter(taskDuration => taskDuration >= 2)
.map(duration => duration * hourlyRate)
.reduce((acc, salary) => acc + salary)
.toFixed(2);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nice!

return taskDurations;
}


// 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)

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

// Do not change or remove anything below this line
module.exports = {
Expand Down
5 changes: 3 additions & 2 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
const doubleOddArr = numbers.filter(num => num % 2)
.map(num => num * 2)
return doubleOddArr;
}

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