Skip to content
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

Ashish Malla #201

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions day_1/exercises/booleans.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
In the exercises below, write your own code where indicated
to achieve the desired result.
to achieve the desired result.

A few are done for you already.

Expand All @@ -18,7 +18,7 @@ console.log(typeof (1 == 1));
console.log(1 == 2);

// example: log to the console the result of 7 is not equal to 2:
console.log(/*your code here*/);
console.log(7 != 2);

// example: log to the console the result of "hello" is equal to "Hello":

console.log("hello" == "Hello");
11 changes: 6 additions & 5 deletions day_1/exercises/concatenation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
In the exercises below, write your own code where indicated
to achieve the desired result.
to achieve the desired result.

A few are completed for you, to provide an example.

Expand All @@ -14,8 +14,8 @@ var team = "Chudley Cannons";

console.log("The " + team + " are " + name + "'s favorite Quidditch team");

// What happens if you include other data types when you use concatination? What data type is logged after we run this code?
// ANSWER to question on line 17:
// What happens if you include other data types when you use concatination? What data type is logged after we run this code? Answer: It will join with other data types. It will log the string data type "My zoo has 7 creatures!"
// ANSWER to question on line 17:

var number = 7;
var creatures = "unicorns";
Expand All @@ -27,7 +27,7 @@ console.log("My zoo has " + number + " " + creatures + "!")
var speedy = "quick red fox";
var slowPoke = "lazy brown dog";

console.log(/*YOUR CODE HERE*/);
console.log("The " + speedy + " jumped over the " + slowPoke);

// Write code that combines the variables below into a string that
// reads "In a predictable result, the tortoise beat the hare!"
Expand All @@ -36,4 +36,5 @@ console.log(/*YOUR CODE HERE*/);
slowPoke = "tortoise";
speedy = "hare";

// YOUR CODE HERE
var combo = "In a predictable result, the "+ slowPoke + " beat the "+ speedy + "!";
console.log(combo);
11 changes: 6 additions & 5 deletions day_1/exercises/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ file from your terminal with the command `node day_1/exercises/numbers.js`
console.log(2 + 2);

// log the result of 7 subtracted from 83 console:
console.log(/*YOUR CODE HERE*/);
console.log(83 - 7);

// log the result of 6 multiplied by 53 to the console:
// YOUR CODE HERE
console.log(6 * 53);

// log the result of 20 divided by 4 to console:
// YOUR CODE HERE
console.log(20 / 4);

// log the result of the modulo of 10 into 54:
// YOUR CODE HERE
console.log(54 % 10);

// log the total number of snacks to the console, using the variables below:
var healthySnackCount = 7;
var junkFoodSnackCount = 4;
// YOUR CODE HERE
var result = healthySnackCount + junkFoodSnackCount;
console.log("Total number of snacks: "+ result);
6 changes: 3 additions & 3 deletions day_1/exercises/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ file from your terminal with the command `node day_1/exercises/strings.js`
console.log("Alan Turing");

// Write code below to log `Welcome to Turing!` in the console:
console.log(/*YOUR CODE HERE*/);
console.log("Welcome to Turing!");

// Write code below to log `99 bottles of pop on the wall...`:
// YOUR CODE HERE
console.log("99 bottles of pop on the wall...");

//Write code below to log one line from your favorite song or movie:
// YOUR CODE HERE
console.log("Interstellar");
9 changes: 5 additions & 4 deletions day_1/exercises/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ console.log(name);
// Write code below to assign the string 'Dobby' to a variable and
// log that variable to the console:
var houseElf = "Dobby";
// YOUR CODE HERE
console.log(houseElf);

// Write code below to save the string 'Harry Potter must not return to Hogwarts!'
// log that variable to the console:
// YOUR CODE HERE
var Hogwarts = "Harry Potter";
console.log(Hogwarts);

// example: Write code below to add 2 to the variable `students` and
// log the result:
var students = 22;
// YOUR CODE HERE
students += 2 ;
console.log(students);

// Write the code below to subtract 2 students from the `students` variable and
// log the result:
// YOUR CODE HERE
students -= 2;
console.log(students);
18 changes: 13 additions & 5 deletions day_1/questions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
## Day 1 Questions

1. How would you log the string `"Hello World!"` to the console?
- console.log("Hello World!");

1. What is the character you would use to indicate comments in a JavaScript file?
2. What is the character you would use to indicate comments in a JavaScript file?
- //for single line comments
- /* for multiple line comments */

1. Explain the difference between an integer and a floating-point number?
3. Explain the difference between an integer and a floating-point number?
- integer is a whole number and floating-point is decimal numbers

1. In the space below, create a variable `animal` that holds the string `"zebra"`.
4. In the space below, create a variable `animal` that holds the string `"zebra"`.
- var animal = "zebra";

1. How would you log the string `"zebra"` using the variable that you created above?
5. How would you log the string `"zebra"` using the variable that you created above?
- console.log(animal);

1. What is concatenation? Use concatenation to log a sentence to the console using the variable `animal`.
6. What is concatenation? Use concatenation to log a sentence to the console using the variable `animal`.
- Concatenation in JavaScript is joining two strings together.
- console.log("Value that's stored in the variable animal is: " + animal);
11 changes: 11 additions & 0 deletions day_2/array_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1. pop
- it removes an item from the end of an Array

2. push
- it adds an item to the end of an Array

3. shift
- it removes an item from the beginning of an Array

4. unshift
- it adds an item to the beginning of an Array
22 changes: 13 additions & 9 deletions day_2/exercises/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,40 @@ var animals = ["Zebra", "Giraffe", "Elephant"];
console.log(animals);

// Declare a variable that will store an an array of at least 3 foods (strings)
// YOUR CODE HERE
var foods = ["Pizza", "Pasta", "Spaghetti"];
console.log(foods);

// example: Write code below that will log the number of elements in array of
// animals from above.
console.log(animals.length);

// Write code below that will log the number of elements in the array of
// foods from above.
// YOUR CODE HERE
console.log(foods.length);

// Write code below that will log "Zebra" from the animals array
// YOUR CODE HERE
console.log(animals[0]);

// Write code using bracket notation that will log the first item in the animals array
// YOUR CODE HERE
console.log(animals[0]);

// Write code using bracket notation that will log the last item in the animals array
// YOUR CODE HERE
console.log(animals[animals.length - 1]);

// Write code using bracket notation that will reassign the last item in the animals
// array to "Gorilla"
// YOUR CODE HERE
animals [2] = "Gorilla";
console.log(animals);

// Write code below that will log the last item from the foods array.
// YOUR CODE HERE
console.log(foods[0]);

// Write code below that uses a method to add "lion" to the animals array and
// log the changed array to verify "lion" has been added
// YOUR CODE HERE
animals.push("lion");
console.log(animals);

// Write code below that removes the last item of food from the foods array and
// log the cahnged array to verify that item has been removed
// YOUR CODE HERE
foods.pop(foods[foods.length-1]);
console.log(foods);
16 changes: 8 additions & 8 deletions day_2/exercises/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ var fourthVar = 0;
console.log(firstVar > secondVar); // this should return: false

// log the result of the comparison: is firstVar less than secondVar?
console.log(); // this should return: true
console.log(firstVar < secondVar); // this should return: true

// log the result of the comparison: is firstVar equal to thirdVar? (use the == operator)
console.log(); // this should return: true
console.log(firstVar == thirdVar); // this should return: true

/*
Note: this is an example of type coercion. Although thirdVar is a string and secondVar is an integer,
Expand All @@ -25,7 +25,7 @@ perform this evaluation
*/

// log the result of the comparison: is firstVar strictly equal to thirdVar? (use the === operator)
console.log(); // this should return: false
console.log(firstVar === thirdVar); // this should return: false

/*
Note: the strictly equal to operator compares the value of the variable in addition to the type of the variable.
Expand All @@ -34,19 +34,19 @@ the comparison still evaluates to false.
*/

// log the result of the comparison: is firstVar not equal to secondVar?
console.log(); // this should return: true
console.log(firstVar != secondVar); // this should return: true

// log the result of the comparison: is secondVar greater than or equal to 20?
console.log(); // this should return: true
console.log(secondVar >= 20); // this should return: true

// log the result of the comparison: is secondVar greater than or equal to 21?
console.log(); // this should return: false
console.log(secondVar >= 21); // this should return: false

// log the result of the comparison: is secondVar less than or equal to 20?
console.log(); // this should return: true
console.log(secondVar <= 20); // this should return: true

// log the result of the comparison: is secondVar less than or equal to 21?
console.log(); // this should return: true
console.log(secondVar <= 21); // this should return: true

// log the result of the comparison: is 0 equal to true?
console.log(0 == true) // this should return: false
Expand Down
16 changes: 12 additions & 4 deletions day_2/exercises/iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ for (var i = 0; i < animals.length; i++) {

// Write code below that iterates through a list of animals and prints "The
// <animal> is awesome!" for each animal.

console.log("-----------------------------");
for (var i = 0; i < animals.length; i++) {
// YOUR CODE HERE
console.log("The "+animals[i]+ " is awesome!");
}

// Create an array of foods and then iterate over that array to log "Add
// <food> to shopping list" for each food item.
// YOUR CODE HERE
console.log("-----------------------------");
var foods = ["Pasta", "Pizza", "Spaghetti"];
for (var i = 0; i < foods.length; i++) {
console.log("Add "+ foods[i]+ " to shopping list");
}

// Create an array of numbers and then iterate over that array to log doubles
// of each of the number.
// YOUR CODE HERE
console.log("-----------------------------");
var nums = [2, 3, 4, 5, 6, 7];
for (var i = 0; i < nums.length; i++) {
console.log(nums[i]*2);
}
6 changes: 4 additions & 2 deletions day_2/exercises/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ for (var i = 0; i < 5; i++) {

// Write code below that logs to the console the sum of 2 plus 2 7 times:
for (var i = 0; i < 7; i++) {
// YOUR CODE HERE
console.log(2+2);
}

// Write code below that prints the phrase 'She sells seashells down by the seashore'
// 10 times.

// YOUR CODE HERE
for (var i = 0; i < 10; i++) {
console.log("She sells seashells down by the seashore");
}
26 changes: 26 additions & 0 deletions day_2/questions.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
## Day 2 Questions

1. Declare a variable named `animals` that stores an array containing the following strings: `"zebra", "giraffe", "elephant"`.
`var animals = ["zebra", "giraffe", "elephant"];`

2. Using the array `animals`, how would you access `"giraffe"`?
`console.log(animals[1]);`

3. How would you add `"lion"` to the `animals` array?
```
animals.push("lion");
console.log(animals);
```

4. Name and describe two additional array methods.
- splice : using splice method we can remove an item by index position
```
var foods = ["Pizza", "Pasta", "Rice"];
var remove = foods.splice(1, 1);
console.log(foods);
```
- slice : using slice method we can make a copy of an Array
```
var copiedFoods = foods.slice();
console.log(copiedFoods);
```

5. What are the boolean values in JavaScript?
- The boolean values are true or false in JavaScript.

6. In JavaScript, how would you evaluate if `2` is equal to `25`? What is the result of this evaluation?
```
console.log(2 == 25);
```
- The result of this evaluation is false.

7. In JavaScript, how would you evaluate if `25` is greater than `2`? What is the result of this evaluation?
```
console.log(25 >= 2);
```
- The result of this evaluation is true.
15 changes: 15 additions & 0 deletions day_3/exercises/decision-making.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,31 @@ if (bearChoice === 1) {
/*
Reflection Questions
1. In English, using technical vocabulary, describe what is happening between lines 17 and 21.
- If the value of doorChoice is equal to 1 then the value "hat" will be assigned to the variable
bearClothing. If not then the value "scarf" will be assigned to the variable bearClothing.

2. What variable has a new value assigned to it after the first if statement executes?
- bearClothing variable has a new value assigned to it after the first if statement executes.

3. If you changed the variable doorChoice to equal 3, what would the bearClothing value be?
- If you changed the variable doorChoice to eqal 3, then the value for bearClothing would be scarf.

4. In English, using technical vocabulary, describe what is happening between lines lines 31 and 38.
- If the value of bearChoice is equal to 1 it will print the string that's inside the log with bearClothing
value hat. If bearChoice doesn't eqal to 1 then it will go to the first else if statement (line 32). If the
value of bearChoice is equal to 2 it will print the string that's inside the log with bearClothing value scarf.
If bearChoice doesn't equal to 2 either then it will go to the second else if statement (line 34). If the
value of bearClothing is equal to 3 then it will print the string that's in the log. If bearClothing doesn't
equal to 3 then it will print the string that's inside the log (line 37). Because we have assigned 1 to the
variable bearChoice it will print You offer the bear your hat and the bear shows you a secret passage out!

5. If you changed the variable bearChoice to equal 3, what will be the final outcome be?
- If I change the variable bearChoice to equal 3 then it will print the string that's inside the log (line 37)

6. If you changed the variable doorChoice to equal 1, and the variable bearChoice to equal 2, what will be the final outcome be?
- If i change the variable doorChoice to equal 1, and the variable bearChoice to equal 2 then it will print the string
that's in the log (line 33).

7. What is your favorite ending?
- My favorite ending is that I get to stay with the bear and become it's best friend!
*/
Loading