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
10 changes: 6 additions & 4 deletions Week1/exercise/w1/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand All @@ -13,7 +13,9 @@ <h2>JS2 - exercise 1</h2>

<div>
<div>
<img src="https://www.w3schools.com/w3css/img_lights.jpg" alt="lights" id="imageToChange" />
<button id="btn-changeHeader">Change Header</button><br><br>
<img src="https://www.w3schools.com/w3css/img_lights.jpg" alt="lights" id="imageToChange" /><br>

</div>

<div>
Expand All @@ -28,11 +30,11 @@ <h3>Todos:</h3>
<li>Learn javascript</li>
<li>Take over the world</li>
</ul>
<input type="text" id="todoInput" />
<input type="text" id="todoInput" placeholder="button"/>
<button id="btn-addTodo">Add todo</button>
</div>
</div>
</body>

<script src="index.js"></script>
<script src="exercise1.js"></script>
</html>
45 changes: 43 additions & 2 deletions Week1/exercise/w1/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@


console.log('Hack your future Belgium!');



// select button byıd

// add event lıstener to that button
//


// EXERCISE 1

// 1a: create a function called "changeHeader", put a console.log() inside this function to test
Expand All @@ -11,9 +21,15 @@ console.log('Hack your future Belgium!');

// 1c: change the inner html of the header element to your name

const h1 = document.querySelector("h1")
function changeHeader() {
console.log("test");
h1.innerHTML ="Rahime";
}

// ====================================== //
document.getElementById("btn-changeHeader").addEventListener("click", changeHeader);

// ====================================== //

// EXERCISE 2

Expand All @@ -30,11 +46,19 @@ console.log('Hack your future Belgium!');
// 2e: to change the image: assign the imageInputValue to the image src


// ====================================== //
function changeImage() {

console.log("test2");
const imageToChange = document.querySelector("img");
const imageInputValue = document.querySelector("#imageInput").value;
imageToChange.src = imageInputValue;
}
document.getElementById("btn-changeImage").addEventListener("click", changeImage);
// ====================================== //

// Exercise 3:


// 3a: select "add todo" button & add click event listener to execute addTodo() function on click event

// 3b: define addTodo() function, in this function:
Expand All @@ -48,3 +72,20 @@ console.log('Hack your future Belgium!');
// 3f: set created <li> element innerHtml to todoInput value

// 3g: add <li> element to todoList


var btn = document.getElementById("btn-addTodo");//a

btn.addEventListener("click", addTodo);//b

function addTodo (){

var myList = document.getElementById("todoList");
var myInput = document.getElementById("todoInput").value;
console.log(myInput);

var newItem = document.createElement("li");
newItem.innerHTML= myInput;
myList.appendChild(newItem);

}
137 changes: 132 additions & 5 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,138 @@
'use strict';

{
const bookTitles = [
// Replace with your own book titles
'harry_potter_chamber_secrets',
];
const bookTitles = [

'pride_and_prejudice',
'animal_farm',
'alice_in_wonderland',
'the_last_leaf',
'the_picture_of_dorian_gray',
'hamlet',
'madame_bovary',
'canterbury_tales',
'emma',
'sense_and_sensibility'

];

// Replace with your own code


// Replace with your own code
console.log(bookTitles);
}
// make an object

const myBookDetailsObj = {
pride_and_prejudice: {
title: 'Pride and Prejudice',
language: 'English',
author: 'Jane Austen',

},

animal_farm: {
title: 'Animal Farm',
language: 'English',
author: 'George Orwell',

},

alice_in_wonderland: {
title: 'Alice in Wonderland',
language: 'English',
author: 'Lewis Carrol',
},

the_last_leaf: {
title: 'The Last Leaf',
language: 'English',
author: 'O.Henry',
},

the_picture_of_dorian_gray: {
title: 'The Picure of Dorian Gray',
language: 'English',
author: 'Oscar Wilde',
},

hamlet: {
title: 'Hamlet',
language: 'English',
author: 'William Shakespeare',
},

madame_bovary: {
title: 'Madame Bovary',
language: 'French',
author: 'Gustave Flaubert',
},

canterbury_tales: {
title: 'Canterbury Tales',
language: 'English',
author: 'Geoffrey Chaucer',
},

anna_karenina: {
title: 'Anna Karenina',
language: 'Russian',
author: 'Leo Tolstoy',
},

sense_and_sensibility: {
title: 'Sence and Sensibility',
language: 'English',
author: 'Jane Austen',
}

};

const bookCoverImagesObj = {
pride_and_prejudice: './assets/pride_and_prejudice.jpg',
animal_farm: './assets/animal_farm.jpg',
alice_in_wonderland: './assets/alice_in_wonderland.jpg',
the_last_leaf: './assets/the_last_leaf.jpg',
the_picture_of_dorian_gray: './assets/the_picture_of_dorian_gray.jpg',
hamlet: './assets/hamlet.jpg',
madame_bovary: './assets/madame_bovary.jpg',
canterbury_tales: './assets/the_canterbury_tales.jpg',
anna_karenina: './assets/anna_karenina.jpg',
sense_and_sensibility: './assets/sense_and_sensibility.jpg'

}


function myFavouredBooks() {
var bookContainer = document.createElement('h1');
h1 = document.createTextNode('My Favoured Books');
document.getElementsByTagName('body')[0].appendChild('h1');


myBookTitles = document.createElement('ul');


for (var key in myBookDetailsObj);

const listItem = document.createElement('li');

listElement.appendChild(listItem);
const title = document.createElement('h2');
header.innerHTML = myBookDetailsObj[key].title;
myBookTitles.appendChild('title');

const images = document.createElement("img");
images.setAttribute("src", bookCoverImagesObj[key]);
images.setAttribute("alt", key);
listItem.appendChild(images);

const author = document.createElement('h3');
author.innerHTML = "Author: " + myBookDetailsObj[key].author;
listItem.appendChild(author);

const language = document.createElement('h3');
language.innerHTML = "Language: " + myBookDetailsObj[key].language;
listItem.appendChild(language);


};
17 changes: 16 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
<!-- replace this with your HTML content -->
<!-- replace this with your HTML content -->

<!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>My Favoured Books</title>
</head>

<body>

<script src="app.js" type="text/javascript" ></script>
</body>
</html>
15 changes: 15 additions & 0 deletions Week2/JSON.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>
<script src="json.js" type="text/javascript"></script>
</body>

</html>
15 changes: 15 additions & 0 deletions Week2/exercises2.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>
<script src="exercises2.js" type="text/javascript"></script>
</body>

</html>
68 changes: 68 additions & 0 deletions Week2/exercises2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//first exercise

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];

function firstElement(n) {

return arr.slice(0, n);

}

firstElement = array[0];

console.log(firstElement(3));
console.log(arr[num]);
// I cannot finish it


//Second exercise

var num = window.prompt();
var str = num.toString();
var result = [str[0]];

for (var i = 1; i < str.length; i++) {
if (str[i - 1] % 2 === 0 && str[i] % 2 === 0) {
result.push('-', str[i]);
} else {
result.push(str[i]);
}
}
console.log(result.join(''));

//third exercise

var arr1 = [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
var mf = 1;
var m = 0;
var item;
for (var i = 0; i < arr1.length; i++) {
for (var j = i; j < arr1.length; j++) {
if (arr1[i] == arr1[j])
m++;
if (mf < m) {
mf = m;
item = arr1[i];
}
}
m = 0;
}
console.log(item + " ( " + mf + " times ) ");

//fourth

var str = 'c';
const UPPER = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const LOWER = 'abcdefghijklmnopqrstuvwxyz';
const result = [];

for (let i = 0; i < str.length; i++) {
if (UPPER.includes(str[i])) {
result.push(str[i].toLowerCase());
} else if (LOWER.includes(str[i])) {
result.push(str[i].toUpperCase());
} else {
result.push(str[i]);
}
}
console.log(result.join(''));
Loading