Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Closed
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
13 changes: 13 additions & 0 deletions Week2/week1/10_last-answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let multiple = [
'string',
23,
false
];

console.log('multiple types in an array : '+ multiple);

console.log('\n');

console.log('6/0 = ' + 6/0);
console.log('10/0 = ' + 10/0);
console.log(6/0 === 10/0);
6 changes: 6 additions & 0 deletions Week2/week1/1_helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
console.log('Halo, dunia!'); //Indenosian
console.log('Ciao, mondo!'); //Italian
console.log('Hola, mundo!'); //Spanish
console.log('Merhaba, dunya!'); //Turkish
console.log('Hello, world'); //English
console.log('\n\n');
3 changes: 3 additions & 0 deletions Week2/week1/2_I'm awesome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log('I\'m awesome');

console.log('\n\n');
13 changes: 13 additions & 0 deletions Week2/week1/3_variable-x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let x;

console.log('the value of my variable x will be: undefined');

console.log('value of x : ' + x);

x = 3;

console.log('the value of my variable x will be: 3');

console.log('value of x : ' + x);

console.log('\n\n');
13 changes: 13 additions & 0 deletions Week2/week1/4_variable-y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let y = 'This is text.';

console.log('the value of my variable y will be: This is text.');

console.log('the value of y : ' + y);

y = 'This is another text.';

console.log('the value of my variable y will be: This is another text.');

console.log('the value of y : ' + y);

console.log('\n\n');
22 changes: 22 additions & 0 deletions Week2/week1/5_variable-z.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let z = 7.25;

console.log(z);

let a = Math.round(z);

console.log(a);

let highest;

if(a > z)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice solution! You can also use math.max. But this is a fine solution!

{
highest = a;
}
else
{
highest = z;
}

console.log('highest is : ' + highest);

console.log('\n\n');
20 changes: 20 additions & 0 deletions Week2/week1/6_arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let fancyAnimals = [];

console.log('the values of my array fancyAnimals will be: ');

console.log('values of fancyAnimals : ' + fancyAnimals);

fancyAnimals = [
'cat',
'dog',
'bird',
'fish'
];

console.log('values of fancyAnimals : ' + fancyAnimals);

fancyAnimals.push('baby pig');

console.log('values of fancyAnimals : ' + fancyAnimals);

console.log('\n\n');
7 changes: 7 additions & 0 deletions Week2/week1/7_strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let myString = "this is a test";

console.log(myString);

console.log('the length of myString : ' + myString.length);

console.log('\n\n');
65 changes: 65 additions & 0 deletions Week2/week1/8_SAME-TYPE.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
let str1 = 'string1';
let num1 = 13;
let bool = true;
let arr = ['cat', 'dog'];
let str2 = 'string2';
let num2 = 14;

console.log("The value of my variable str1 is: " + str1);
console.log("The value of my variable num1 is: " + num1);
console.log("The value of my variable bool is: " + bool);
console.log("The values of my variable arr is: " + arr);
console.log("The value of my variable str2 is: " + str2);
console.log("The value of my variable num2 is: " + num2);
console.log('\n');

console.log('the type of str1 will be: String');
console.log('the type of num1 will be: Number');
console.log('the type of bool will be: Boolean');
console.log('the type of arr will be: Object');
console.log('the type of str2 will be: String');
console.log('the type of num2 will be: Number');
console.log('\n');

console.log('the type of str1 is: ' + typeof(str1));
console.log('the type of num1 is: ' + typeof(num1));
console.log('the type of bool is: ' + typeof(bool));
console.log('the type of arr is: ' + typeof(arr));
console.log('the type of str2 is: ' + typeof(str2));
console.log('the type of num2 is: ' + typeof(num2));
console.log('\n');

let variables = [];
variables[0] = str1;
variables[1] = num1;
variables[2] = bool;
variables[3] = arr;
variables[4] = str2;
variables[5] = num2;

let variableName = [
'str1',
'num1',
'bool',
'arr',
'str2',
'num2'
];

for(let i = 0; i < (variables.length - 1); i++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wow, advanced solution! Really nice!

{
for(let j = (i + 1); j < variables.length; j++)
{
if(typeof(variables[i]) == typeof(variables[j]))
{
console.log(variableName[i] + ' and ' + variableName[j] + ' are : SAME TYPE');
}
else
{
console.log(variableName[i] + ' and ' + variableName[j] + ' are : NOT SAME TYPE');
}
}
console.log('\n');
}

console.log('\n\n');
12 changes: 12 additions & 0 deletions Week2/week1/9_modulo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
for(let x = 1; x < 8; x++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cool that you know how to use loops already! Will help a lot in future courses

{
console.log('the value of x is : ' + x);
if(x == 7)
{
x = (x % 3);
console.log('When the value of x is : 7, the value of x changed to : ' + x);
break;
}
}

console.log('\n\n');
21 changes: 21 additions & 0 deletions Week2/week1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<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="1_helloworld.js"></script>
<script src="2_I'm awesome.js"></script>
<script src="3_variable-x.js"></script>
<script src="4_variable-y.js"></script>
<script src="5_variable-z.js"></script>
<script src="6_arrays.js"></script>
<script src="7_strings.js"></script>
<script src="8_SAME-TYPE.js"></script>
<script src="9_modulo.js"></script>
<script src="10_last-answer.js"></script>

</body>
</html>
8 changes: 8 additions & 0 deletions Week3/week2/1-strings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let myString = "hello,this,is,a,difficult,to,read,sentence";

console.log(myString);
console.log(myString.length);
myString = myString.replace(/,/g , " ");
console.log(myString);

console.log("\n\n");
17 changes: 17 additions & 0 deletions Week3/week2/2-arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let favoriteAnimals = ["blowfish", "capricorn", "giraffe"];

favoriteAnimals.push("turtle");
console.log(favoriteAnimals);

favoriteAnimals.splice(1, 0, "meerkat");
console.log("New value of favoriteAnimals will be : blowfish, meerkat, capricorn, giraffe, turtle");
console.log(favoriteAnimals);

console.log("The array has a length of: " + favoriteAnimals.length);

favoriteAnimals.splice(3, 1);
console.log(favoriteAnimals);

console.log("The item you are looking for is at index: " + favoriteAnimals.indexOf("meerkat"));

console.log("\n\n");
29 changes: 29 additions & 0 deletions Week3/week2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<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="1-strings.js"></script>
<script src="2-arrays.js"></script>
<script src="moreJavaScript-1.js"></script>
<script src="moreJavaScript-2.js"></script>
<script src="moreJavaScript-3.js"></script>
<script src="moreJavaScript-4.js"></script>
<script src="moreJavaScript-5.js"></script>
<script src="moreJavaScript-6.js"></script>
<script src="moreJavaScript-7.js"></script>
<script src="moreJavaScript-8.js"></script>
<script src="moreJavaScript-9.js"></script>
<script src="moreJavaScript-10.js"></script>
<script src="moreJavaScript-11.js"></script>
<script src="moreJavaScript-12.js"></script>
<script src="moreJavaScript-13.js"></script>
<script src="moreJavaScript-14.js"></script>
<script src="moreJavaScript-15.js"></script>
<script src="moreJavaScript-16.js"></script>
<script src="moreJavaScript-17.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions Week3/week2/moreJavaScript-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function sum(arg1, arg2, arg3) {
if(isNaN(arg1) || isNaN(arg2) || isNaN(arg3)) {
return "least one of parameters is not a number!";
}
return arg1 + arg2 + arg3;
}

console.log(sum(1, 2, "afaf"));
console.log(sum(1, 2, 3));
console.log("\n\n");
10 changes: 10 additions & 0 deletions Week3/week2/moreJavaScript-10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function advertisement(vehicles) {
let text = "Amazing Joe's Garage, we service ";
for(let index = 0; index < (vehicles.length - 2); index++) {
text += (vehicles[index] + ", ");
}
console.log(text + vehicles[vehicles.length -2] + " and " + vehicles[vehicles.length -1] + ".");
}

advertisement(vehicles);
console.log("\n\n");
3 changes: 3 additions & 0 deletions Week3/week2/moreJavaScript-11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vehicles.push("truck");
advertisement(vehicles);
console.log("\n\n");
4 changes: 4 additions & 0 deletions Week3/week2/moreJavaScript-12.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let objc = {};

console.log(objc);
console.log("\n\n");
7 changes: 7 additions & 0 deletions Week3/week2/moreJavaScript-13.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let teachers = {
name : ["Philip", "Unmesh", "Sander"],
country : ["Germany", "India", "Netherland"]
}

console.log(teachers);
console.log("\n\n");
4 changes: 4 additions & 0 deletions Week3/week2/moreJavaScript-14.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
teachers.languages = ["HTML-CSS", "GIT", "JAVASCRIPT"];

console.log(teachers);
console.log("\n\n");
9 changes: 9 additions & 0 deletions Week3/week2/moreJavaScript-15.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let x = [1, 2, 3];
let y = [1, 2, 3];
let z = y;

console.log(x == y);
console.log(x === y);
console.log(z == y);
console.log(z == x);
console.log("\n\n");
30 changes: 30 additions & 0 deletions Week3/week2/moreJavaScript-16.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
let o1 = { foo: "bar" };
let o2 = { foo: "bar" };
let o3 = o2;

console.log(o1);
console.log(o2);
console.log(o3);
console.log("\n");

console.log(o3);
o2.foo = "bar2";
console.log(o3); // Yes it changes
console.log("\n");

console.log(o3);
o1.foo = "barX";
console.log(o3); // No it doesn't change
console.log("\n");

console.log(o1);
console.log(o2);
console.log(o3);
console.log("\n");

o2 = o3;

console.log(o1);
console.log(o2);
console.log(o3);
console.log("\n\n");
5 changes: 5 additions & 0 deletions Week3/week2/moreJavaScript-17.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let bar = 42;

let result = typeof bar;
result = typeof result; // result = typeof typeof bar;
console.log(result);
11 changes: 11 additions & 0 deletions Week3/week2/moreJavaScript-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function colorCar(color) {
if(typeof(color) !== "string") {
console.log(color + " is not a string!");
} else {
console.log("a " + color +" car");
}
}

colorCar(2);
colorCar("red");
console.log("\n\n");
Loading