diff --git a/Week2/%.js b/Week2/%.js new file mode 100644 index 000000000..7f979a060 --- /dev/null +++ b/Week2/%.js @@ -0,0 +1,8 @@ +// Explaining % + +x = 12; +console.log(x); + +console.log ('x % 5 will be 2 which is the leftover number that cannot be divided on 5'); + +console.log(x % 5); \ No newline at end of file diff --git a/Week2/arrays.js b/Week2/arrays.js new file mode 100644 index 000000000..7fbd5ee8a --- /dev/null +++ b/Week2/arrays.js @@ -0,0 +1,15 @@ +// Animals Names + +let myFavoriteAnimals; + +console.log('The value of myFavoriteAnimals is: undefined then an object \'array\' '); + +console.log(myFavoriteAnimals); + +myFavoriteAnimals = ['monkey', 'horse', 'turtle']; + +console.log(myFavoriteAnimals); + +myFavoriteAnimals = myFavoriteAnimals + [', baby pig']; + +console.log(myFavoriteAnimals); \ No newline at end of file diff --git a/Week2/dataType.js b/Week2/dataType.js new file mode 100644 index 000000000..104649d32 --- /dev/null +++ b/Week2/dataType.js @@ -0,0 +1,61 @@ +// Types of Data + +let success = 'Congats! the data type of your variables is identical!'; + +console.log(success + ' * this is a string'); + +console.log(typeof success); + + +let failure = 'Oops! the data type of your variables is different!'; + +console.log(failure + ' * this is a string'); + +console.log(typeof failure); + + +let number = 1; + +console.log(number + ' * this is a number'); + +console.log(typeof number); + + +let boolean = true; + +console.log(boolean + ' * this is a boolean'); + +console.log(typeof boolean); + + +let array = [0, 1, 2, 3, 4]; + +console.log(array + ' * this is an object'); + +console.log(typeof array); + +// Testing type of data + +if (typeof success === typeof failure) { + + console.log(success); + +} else { + console.log(failure); +} + + +if (typeof success === typeof number) { + console.log(success); + +} else { + console.log(failure); +} + + +if (typeof boolean === typeof array) { + console.log(success); + +} else { + console.log(failure); +} diff --git a/Week2/helloWorld.js b/Week2/helloWorld.js new file mode 100644 index 000000000..8fe96f56f --- /dev/null +++ b/Week2/helloWorld.js @@ -0,0 +1,11 @@ +// Greetings + +console.log ('Hello World!'); //English + +console.log ('Halo, Dunia!'); // Indonesian + +console.log ('Ciao Mondo!'); // Italian + +console.log ('Hola Mundo!'); // Spanish + + diff --git a/Week2/imAwesome.js b/Week2/imAwesome.js new file mode 100644 index 000000000..520fbbda3 --- /dev/null +++ b/Week2/imAwesome.js @@ -0,0 +1,17 @@ +// Debug single quote issue + +console.log('I\'m awesome'); + +// variables & Values + +let x; + +console.log("the value of my variable x will be: undefined "); + +console.log(x); + +x = 12; + +console.log("the value of my variable x will be: a number 12 "); + +console.log(x); \ No newline at end of file diff --git a/Week2/index.html b/Week2/index.html new file mode 100644 index 000000000..567877d9f --- /dev/null +++ b/Week2/index.html @@ -0,0 +1,30 @@ + + + + + + + Codestin Search App + + +

JS-week2

+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week2/moreStrings.js b/Week2/moreStrings.js new file mode 100644 index 000000000..5314697f0 --- /dev/null +++ b/Week2/moreStrings.js @@ -0,0 +1,7 @@ +// String Length + +let myString = "this is a test"; + +console.log(myString); + +console.log(myString.length); \ No newline at end of file diff --git a/Week2/multiDataTypes.js b/Week2/multiDataTypes.js new file mode 100644 index 000000000..76734c776 --- /dev/null +++ b/Week2/multiDataTypes.js @@ -0,0 +1,16 @@ +// Array with multiple data types + +console.log('following array contains 2 numbers, 2 strings and a boolean'); + +let multipleTypesArray = [0, 'hero', 2, 'too', false]; + +console.log(multipleTypesArray); + +// Comparing infinities + +if (10/0 === 6/0) { + console.log('Yes! they\'re equal!'); + +} else { + console.log('There\'s no equality in this!'); +} \ No newline at end of file diff --git a/Week2/roundNumber.js b/Week2/roundNumber.js new file mode 100644 index 000000000..0679cdb01 --- /dev/null +++ b/Week2/roundNumber.js @@ -0,0 +1,24 @@ + +let z = 7.25; + +console.log(z); + +// Round z to the closest integer + +let round = Math.round; + +let a = round(z); + +console.log(a); + +// Print higher value z or a + +if (a + + + + + + Codestin Search App + + + +

JS-week3

+ + ` + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week3/strings.js b/Week3/strings.js new file mode 100644 index 000000000..16c2e1c46 --- /dev/null +++ b/Week3/strings.js @@ -0,0 +1,6 @@ +let myString = "hello,this,is,a,difficult,to,read,sentence"; + +console.log(myString.length); + +console.log(myString.replace(/,/g," ")); + diff --git a/Week3/sumFun.js b/Week3/sumFun.js new file mode 100644 index 000000000..21ddb800f --- /dev/null +++ b/Week3/sumFun.js @@ -0,0 +1,13 @@ +// Create a function that takes 3 arguments and returns the sum of the these arguments. + +function sum(){ + let sum =0; + for(let i=0;i