This repository was archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
Veli Ataseven JavaScript Homework Week 1 #109
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| console.log('I\'m awesome'); | ||
|
|
||
| console.log('\n\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| { | ||
| highest = a; | ||
| } | ||
| else | ||
| { | ||
| highest = z; | ||
| } | ||
|
|
||
| console.log('highest is : ' + highest); | ||
|
|
||
| console.log('\n\n'); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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++) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| for(let x = 1; x < 8; x++) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| vehicles.push("truck"); | ||
| advertisement(vehicles); | ||
| console.log("\n\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| let objc = {}; | ||
|
|
||
| console.log(objc); | ||
| console.log("\n\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!