Skip to content
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
Binary file added Week1/homework/background.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/img/5th_horseman.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/img/da_vinci_code.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/img/duc_man.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/img/hunger games 1.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/img/hunger_games_mockingjay.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/img/improbable.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/img/miserables.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/img/parbat.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/img/peetvader.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/img/under_ocean.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions Week2/class exercise array/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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>Document</title>
</head>

<body></body>

<script src="index.js"></script>
</html>
93 changes: 93 additions & 0 deletions Week2/class exercise array/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//JS function to return first element, and pass a number as parameter
const arrayMine = [
'paramater_is_study',
1,
'time',
'great op',
'good work',
1,
2,
2341,
'parameter',
'time',
];
console.log(arrayMine);

var n = window.prompt('Please enter first how many numbers you want to log');
var num1 = parseInt(n);

function nthItem(array, num1) {
var arrayX = [];
for (let i = 0; i < num1; i++) {
arrayX.push(array[i]);
}
return arrayX;
}
console.log(nthItem(arrayMine, n));

//a function which accepts a number as input and insert dashes btw each two even number:
function evenNumbers() {
var number = window.prompt('Please enter a number');
const string = number.toString();
const result = [string[0]];
for (let i = 0; i < string.length; i++) {
if (string[i - 1] % 2 === 0 && string[i] % 2 === 0) {
result.push('-', string[i]);
} else if (string[i - 1] % 2 === 1 && string[i] % 2 === 0) {
result.push(string[i]);
} else if (string[i - 1] % 2 === 0 && string[i] % 2 === 1) {
result.push('-', string[i]);
} else if (string[i - 1] % 2 === 1 && string[i] % 2 === 1) {
result.push(string[i]);
}
}
console.log(result.join(''));
}
evenNumbers();

//finding the most frequent item of an array
function findMostFrequent(array) {
var map = {};
var mostFrequentElement = array[0];
for (var i = 0; i < array.length; i++) {
if (!map[array[i]]) {
map[array[i]] = 1;
} else {
++map[array[i]];
if (map[array[i]] > map[mostFrequentElement]) {
mostFrequentElement = array[i];
console.log('The most frequent element of the array is: ' + mostFrequentElement);
} else if (map[array[i]] === map[mostFrequentElement]) {
console.log('The array has more than one most frequent elements');
console.log(
'The most frequent elements of the array are: ' + mostFrequentElement + ', ' + array[i],
);
}
}
}
}

findMostFrequent(arrayMine);

//function accepting a string as input and swapping the case of each character
function swapCase() {
var str = window.prompt('Please enter something');

//first we define the alphabet and check the letters according to that
var upperCases = 'ABCÇDEFGHIİJKLMNOÖPQRSTUÜVWXYZ';
var lowerCases = 'abcçdefghıijklmnoöpqrstuüvwxyz';

//we will check each letter according to upper and lower case and transform it:
var result = [];
for (var x = 0; x < str.length; x++) {
if (upperCases.indexOf(str[x]) !== -1) {
result.push(str[x].toLowerCase());
} else if (lowerCases.indexOf(str[x]) !== -1) {
result.push(str[x].toUpperCase());
} else {
result.push(str[x]);
}
}
console.log(result.join(''));
}
swapCase();
15 changes: 15 additions & 0 deletions Week2/class exercise json/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!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>Document</title>
</head>

<body onload="countTime()">
<div id="txt"></div>
</body>

<script src="index.js"></script>
</html>
76 changes: 76 additions & 0 deletions Week2/class exercise json/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//JS program for getting the length of an object
var myObj = {};
myObj['full'] = 'Galatasaray';
myObj['short'] = 'GS';
myObj['league'] = 'Super League';
myObj['position'] = 1;
Object.size = function(obj) {
var size = 0,
key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};

var size = Object.size(myObj);
console.log('The length of the object is: ' + size);

//js function to check if object contains given prop
var x = window.prompt('Please enter a property to check if it exist in the object');
Object.check = function(obj, x) {
for (let key in obj) {
if (x === obj.hasOwnProperty(key)) console.log('This is a property of object');
else console.log("This property doesn't exist in this object");
}
};
Object.check(myObj);

//js program to create clock, console the seconds to html
function countTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML = h + ':' + m + ':' + s;
var t = setTimeout(countTime, 500);
}
function checkTime(i) {
if (i < 10) {
i = '0' + i;
} // add zero in front of numbers < 10
return i;
}

//js program to create clock, console the seconds
function my_Clock() {
this.cur_date = new Date();
this.hours = this.cur_date.getHours();
this.minutes = this.cur_date.getMinutes();
this.seconds = this.cur_date.getSeconds();
}
my_Clock.prototype.run = function() {
setInterval(this.update.bind(this), 1000);
};
my_Clock.prototype.update = function() {
this.updateTime(1);
console.log(this.hours + ':' + this.minutes + ':' + this.seconds);
};
my_Clock.prototype.updateTime = function(secs) {
this.seconds += secs;
if (this.seconds >= 60) {
this.minutes++;
this.seconds = 0;
}
if (this.minutes >= 60) {
this.hours++;
this.minutes = 0;
}
if (this.hours >= 24) {
this.hours = 0;
}
};
var clock = new my_Clock();
clock.run();
14 changes: 14 additions & 0 deletions Week2/homework/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!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>Document</title>
</head>

<body></body>

<script src="map-filter.js"></script>
<script src="maartjes-work.js"></script>
</html>
8 changes: 5 additions & 3 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ 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 hourTasks = tasks.map(key => key.duration / 60); //Map the tasks to durations in hours.
const filteredTasks = hourTasks.filter(dur => dur >= 2); //Filter out everything that took less than two hours (i.e., remove from the collection)
const earningTasks = filteredTasks.map(dur => (dur += dur * hourlyRate)); //Multiply the each duration by a per-hour rate for billing (use €20/hour) and sum it all up.
return earningTasks;
}

// 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 €${Number.parseFloat(earnings).toFixed(2)}`); //Output a formatted Euro amount, rounded to Euro cents, e.g: €11.34.

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

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

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
const myNumbers = [1, 2, 3, 4, 5, 6];
console.log(doubleOddNumbers(myNumbers)); // ==> [2, 6, 10]

// Do not change or remove anything below this line
module.exports = {
Expand Down