Thanks to visit codestin.com
Credit goes to github.com

Skip to content

finished homework for Javascript week1 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
Binary file added Week1/homework/README.MD
Binary file not shown.
11 changes: 11 additions & 0 deletions Week1/homework/js-exercises/01logHello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'
console.log("Halo, dunia!"); // Indonesian
console.log("Ciao, mondo!"); // Italian
console.log("Hola, mundo!"); // Spanish
console.log("你好, 世界!"); // Chinese
console.log("こんにちは, 世界!"); // Japanese
console.log("Здравствуй, мир!"); // Russian
console.log("여보세요, 세계!"); // Korean
console.log("Olá, mundo!"); // "Portuguese"
console.log("γειά σου, κόσμος!"); // "Greek"
console.log("Bonjour, monde!"); // French
2 changes: 2 additions & 0 deletions Week1/homework/js-exercises/02debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict'
console.log('I\'m awesome');
13 changes: 13 additions & 0 deletions Week1/homework/js-exercises/03logNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
// 1. First, declare your variable `numberX`. Do not _initialize_ it (which means, don't give it a value) yet.
let numberX;
// 2. Add a `console.log` statement that explains in words _what you think_ the value of `x` is, like in this example.
console.log("I think it is 'undefined'");
// 3. Add a `console.log` statement that logs the value of `numberX`.
console.log(numberX);
// 4. Now _initialize_ your variable `numberX` with a number (also called an `integer` in computer science terms).
numberX = 10;
// 5. Next, add a `console.log` statement that explains _what you think_ the value of `numberX` is.
console.log("I think it is number '10'");
// 6. Add a `console.log` statement that logs the value of `numberX`.
console.log(numberX);
13 changes: 13 additions & 0 deletions Week1/homework/js-exercises/04logString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
// 1. Declare a variable `myString` and assign a string to it. Use your full name, including spaces, as the content for the string.
let myString = "Mustafa TUNCER";
// 2. Write a `console.log` statement in which you explain in words _what you think_ the value of the string is.
console.log("It should print \"Mustafa TUNCER\"");
// 3. Now `console.log` the variable `myString`.
console.log(myString);
// 4. Now reassign to the variable `myString` a new string.
myString = myString.split(' ')[0];
// 5. Just like what you did before write a `console.log` statement that explains in words _what you think_ will be logged to the console.
console.log("It should print \"Mustafa\"");
// 6. Now console.log `myString` again.
console.log(myString);
13 changes: 13 additions & 0 deletions Week1/homework/js-exercises/05roundANumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'
// 1. Declare a variable `z` and assign the number 7.25 to it.
let z = 7.25;
// 2. Write a `console.log` statement in which you log the value of `z`.
console.log(z);
// 3. Declare another variable `a` that has the value of `z` but rounded to the nearest integer.
let a = Math.round(z);
// 4. Write a `console.log` statement in which you log the value of `a`.
console.log(a);
// 5. So now we have `z` and `a` find a way to compare the two values and store the highest of the two in a new variable.
let j = a > z ? a : z;
// 6. Write a `console.log` statement in which you log the value of the highest value.
console.log(j);
15 changes: 15 additions & 0 deletions Week1/homework/js-exercises/06logArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'
// 1. Declare variable and assign to it an empty array. Make sure that the name of the variable indicates it contains more than 1 item. For example `items` instead of `item`.
const items = [];
// 2. Write a `console.log` statement that explains in words _what you think_ the value of the array is.
console.log("The value of the array should be an empty array. '[]'");
// 3. Write a `console.log` statement that logs the array.
console.log(items);
// 4. Create a new variable with an array that has 3 of your favorite animals, each in a different string. Make sure the name of the variables says something about what the variable contains.
const pets = ['Horse', "Pikachu", `Parrot`];
// 5. Write a `console.log` statement that logs the second array.
console.log(pets);
// 6. Add a statement that adds another string ("Piglet)" to the array of animals.
pets.push("Piglet");
// 7. Write a `console.log` statement that logs the second array!
console.log(pets);
7 changes: 7 additions & 0 deletions Week1/homework/js-exercises/07logStringLength.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
// 1. Declare a variable called `mySentence` and initialize it with the following string: "Programming is so interesting!".
let mySentence = "Programming is so interesting!";
// 2. Figure out (using Google) how to get the length of `mySentence`.
let lengthOfTheString = mySentence.length;
// 3. Write a `console.log` statement to log the length of `mySentence`.
console.log(lengthOfTheString);
24 changes: 24 additions & 0 deletions Week1/homework/js-exercises/08typeCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'
// 1. Declare 4 variables: 2 must be `strings` and 2 must be `objects`
let s1 = "a";
let s2 = "b";
let o1 = null;
let o2 = {};
// 2. Create 8 conditional statements, where for each you check if the data type of one variable is the same as the other
console.log(typeof s1 === typeof s2);
console.log(typeof s1 === typeof o1);
console.log(typeof s1 === typeof o2);
console.log(typeof s2 === typeof o1);
console.log(typeof s2 === typeof o2);
console.log(typeof o1 === typeof o2);
console.log(typeof s1 === typeof s1);
console.log(typeof s2 === typeof s2);
// 3. Find out how to check the type of a variable
console.log("To find the type of a variable, we use 'typeof'");
// 4. Write 2 `console.log` statements to log the type of 2 variables, each with a different data type
console.log(typeof s1);
console.log(typeof o1);
// 5. Now compare the types of your different variables with one another
console.log(typeof s1 === typeof s2);
// 6. Log `Not the same...` when the types are different
console.log(typeof s1 === typeof o1 ? "The same" : "Not the same...");
15 changes: 15 additions & 0 deletions Week1/homework/js-exercises/09logRemainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'
// 1. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the value of `x` after the calculation?
let x = 7;
x = x % 3;
console.log("Expecting 1, Remainder is: ", x);
// 2. If `y` equals 21, and the only other statement is `x = x % 4`, what would be the value of `y` after the calculation?
let y = 21;
x = x % 4;
console.log("Since the operation is for the X, y should be 21, and it is: ", y);
console.log("Lets say it was for y. for y = 21; y % 4 should be 1. It is: ", y % 4);
// 3. If `z` equals 13, and the only other statement is `x = x % 2`, what would be the value of `z` after the calculation?
let z = 13;
x = x % 2;
console.log("Since the operation is for the X, z should be 13, and it is: ", z);
console.log("Lets say it was for z. for z = 13; z % 2 should be 1. It is: ", z % 2);
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/10compareArrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'
// 1. Declare 2 variables, that each hold an array. The first array should have 4 items, the second 7 items
const tools = ['hammer', 'axe', 'screwdriver', 'wrench'];
const animals = ['rabbit', 'hare', 'hamster', 'cow', 'sheep', 'goat', 'donkey'];
// 2. Find out how to get the length of each array. Write a `console.log` statement that shows the length of each array
console.log("The length of tools array is: ", tools.length);
console.log("The length of animals array is: ", animals.length);
// 3. Write a conditional statement that checks if both are of equal length. If they are, log to the console `They are the same!`, if not log `Two different sizes`
console.log(tools.length === animals.length ? "They are the same!" : "Two different sizes");