From 60123e1738a2424eb577c8d1c567d355708da6e4 Mon Sep 17 00:00:00 2001 From: aalitenaye Date: Sun, 25 Aug 2019 17:50:36 -0400 Subject: [PATCH 1/2] week6 assignment submission --- Q-1.js | 4 ++++ Q-10.js | 6 ++++++ Q-11.js | 4 ++++ Q-12.js | 10 ++++++++++ Q-13.js | 4 ++++ Q-2.js | 6 ++++++ Q-3.js | 9 +++++++++ Q-4.js | 11 +++++++++++ Q-5.js | 16 ++++++++++++++++ Q-6.js | 14 ++++++++++++++ Q-7.js | 6 ++++++ Q-8.js | 5 +++++ Q-9.js | 13 +++++++++++++ 13 files changed, 108 insertions(+) create mode 100644 Q-1.js create mode 100644 Q-10.js create mode 100644 Q-11.js create mode 100644 Q-12.js create mode 100644 Q-13.js create mode 100644 Q-2.js create mode 100644 Q-3.js create mode 100644 Q-4.js create mode 100644 Q-5.js create mode 100644 Q-6.js create mode 100644 Q-7.js create mode 100644 Q-8.js create mode 100644 Q-9.js diff --git a/Q-1.js b/Q-1.js new file mode 100644 index 0000000..79d90e8 --- /dev/null +++ b/Q-1.js @@ -0,0 +1,4 @@ +// Q-1: Write a console.log statement saying "Hello World!" for each language that you know. +console.log('Hello World!'); //English language +console.log('سلام دنیا'); // Persian Language +console.log('ہیلو دنیا') // Urdu Language diff --git a/Q-10.js b/Q-10.js new file mode 100644 index 0000000..5bfd02c --- /dev/null +++ b/Q-10.js @@ -0,0 +1,6 @@ +// I’ve declared a multidimensional array (an array inside an array) -- see below. Add a console.log statement accessing this item. +const grid = [[0, 1], [1, 1], [2, 1], [3, 1]]; +// How can I access the third item’s second element? i.e. [2, 1] is the third element, and I want to access 1. +const item = grid[2][1]; +console.log(grid.length); +console.log(item); diff --git a/Q-11.js b/Q-11.js new file mode 100644 index 0000000..ec8f36a --- /dev/null +++ b/Q-11.js @@ -0,0 +1,4 @@ +// Q-11: If I have a variable counter, and I want to increment it by 2, what are three ways I can do this? Add three console.log statements with the three different ways. +let counter = 0; +counter = counter + 1; +console.log(++counter); diff --git a/Q-12.js b/Q-12.js new file mode 100644 index 0000000..52cecc5 --- /dev/null +++ b/Q-12.js @@ -0,0 +1,10 @@ +//Q-12: Here’s a profile about a cat for adoption. Create variables to hold information about this cat as shown on the profile. For example: +const name = 'Prince'; +const bestFriend = 'Thomas'; +const adoptBoth = 'Both'; +const breed = 'Domestic Shorthair'; +const color = 'Orange or Red Tabby'; +const age = '1 year old, Young'; +let sex = 'Male'; +let petId = ''; +let hair = 'Short'; diff --git a/Q-13.js b/Q-13.js new file mode 100644 index 0000000..254e424 --- /dev/null +++ b/Q-13.js @@ -0,0 +1,4 @@ +//Q-13: Create two variables -- one to hold the names of the kittens and one to hold the names of the adult cats. Make sure to choose an appropriate data type to hold this information! + +let nameAdult = 'Mezzo','Sabrina','Josie'; +let nameKitten = 'Kyle Meowry','Luna','Obi','Charlie','Raspberries'; diff --git a/Q-2.js b/Q-2.js new file mode 100644 index 0000000..4f8d01c --- /dev/null +++ b/Q-2.js @@ -0,0 +1,6 @@ +// Q-2: Consider the following code: + +console.log('I'm awesome'); + +// The problem is in the wronge use of SINGLE QOUTE in I'm. To solve this problem we will have to replace the outer single qoutes to double quotes. +// w3school "You can use quotes inside a string, as long as they don't match the quotes surrounding the string:" diff --git a/Q-3.js b/Q-3.js new file mode 100644 index 0000000..18b9777 --- /dev/null +++ b/Q-3.js @@ -0,0 +1,9 @@ +// Declare a variable age and initialize it with an integer, using these exact steps: + +// ANSWER +let age; // declare variable +console.log('The value of age will be: twentyFive'); // Explain the value of age +console.log(age); // logged the value of age +age = 25; // initialized variable age with an integer +console.log('The value of age will be: twentyFive'); // add a console.log statement that explains what you think the value of age is. +console.log(age); // Add a console.log statement that logs the value of age. diff --git a/Q-4.js b/Q-4.js new file mode 100644 index 0000000..1fd566c --- /dev/null +++ b/Q-4.js @@ -0,0 +1,11 @@ +// Q-4: Declare a variable name and assign a string to it. + +// ANSWERS + +// Write a console.log statement in which you explain in words what you think the value of the string is. +let string = 'This is my string'; +console.log('The value of my string will be: thisIsMyString'); +console.log(string); +string = 'New string to variable name'; +console.log('The new value of my string is: newStringToVariableName'); +console.log(string); diff --git a/Q-5.js b/Q-5.js new file mode 100644 index 0000000..4ce7051 --- /dev/null +++ b/Q-5.js @@ -0,0 +1,16 @@ +// Q-5: How do you round the number 7.25, to the nearest integer (i.e., whole number)? + +//ANSWER + +//Declare a variable number and assign the number 7.25 to it. +let number = 7.25; +console.log(number); +// Declare another variable roundedNumber that has the value of number but rounded to the nearest integer. +var roundedNumber = Math.round(7.25); +console.log(+ roundedNumber); + +// So now we have number and roundedNumber find a way to compare the two values and store the highest of the two in a new variable. Console.log the highest value. +console.log(7.25 > 7); + +let highest = 7.25; +console.log(highest); diff --git a/Q-6.js b/Q-6.js new file mode 100644 index 0000000..f88ad69 --- /dev/null +++ b/Q-6.js @@ -0,0 +1,14 @@ +// Q-6 ARRAYS +// Declare an empty array. Make sure that the name you choose indicates 'plurality', because an array is capable of containing more than one element. +const friendNames = []; +//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 is :','Empty'); +// console.log your array +console.log(friendNames); +//Create an array that has your favorite animals inside (see if you can find a good name that exactly describes what this variable will hold). +const favoriteAnimales = ['Lion','Owl','Raccoon']; +//Log your array. +console.log(favoriteAnimales); +// Add a statement that adds Syeda’s favorite animal ('kitten') to the existing array. Log your new array +favoriteAnimales.push('Kitten'); +console.log(favoriteAnimales); diff --git a/Q-7.js b/Q-7.js new file mode 100644 index 0000000..3421624 --- /dev/null +++ b/Q-7.js @@ -0,0 +1,6 @@ +//Q-7: More strings: Let's consider the following string: let myString = "this is a test". +// Add the string to your file and console.log it. +let myString = 'this is a test'; +console.log(myString); +// Find a way to get the length of myString.console.log the length of myString. +console.log(myString.length); diff --git a/Q-8.js b/Q-8.js new file mode 100644 index 0000000..561405f --- /dev/null +++ b/Q-8.js @@ -0,0 +1,5 @@ +// If x equals 7, and the only other statement is x = x % 3, what would be the new value of x? +console.log(7%3); // the new value = 1 +//Add at least 3 console.log statements in which you show that you understand what % does. +console.log(10%5); +console.log(13%2); diff --git a/Q-9.js b/Q-9.js new file mode 100644 index 0000000..c7d324d --- /dev/null +++ b/Q-9.js @@ -0,0 +1,13 @@ +// Q-9: Write a program to answer the following questions: + +//ANSWERS +// Can you store multiple types in an array? Numbers and strings? Make an example that illustrates your answer. +const favoritesPlacesAndNumbers = ['India','17','Tajikistan','100']; +console.log(favoritesPlacesAndNumbers); +// Can you compare infinities? +console.log('could not answer this question?'); +// Does 6/0 === 10/0? How can you test this? +let x = 6/0; +let y = 10/0; +console.log(6/0 === 10/0); +// Add console.log statements to the above program in which you show that you understand the concepts (just like you've done in the above assignments). From 1de680cfe9875a192f4bc5cc3c1fa3649fd04eda Mon Sep 17 00:00:00 2001 From: aalitenaye Date: Sun, 25 Aug 2019 18:09:57 -0400 Subject: [PATCH 2/2] 2nd Commit --- Q-1.js => Q1.js | 0 Q-10.js => Q10.js | 0 Q-11.js => Q11.js | 0 Q-12.js => Q12.js | 0 Q-13.js => Q13.js | 0 Q-2.js => Q2.js | 0 Q-3.js => Q3.js | 0 Q-4.js => Q4.js | 0 Q-5.js => Q5.js | 0 Q-6.js => Q6.js | 0 Q-7.js => Q7.js | 0 Q-8.js => Q8.js | 0 Q-9.js => Q9.js | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename Q-1.js => Q1.js (100%) rename Q-10.js => Q10.js (100%) rename Q-11.js => Q11.js (100%) rename Q-12.js => Q12.js (100%) rename Q-13.js => Q13.js (100%) rename Q-2.js => Q2.js (100%) rename Q-3.js => Q3.js (100%) rename Q-4.js => Q4.js (100%) rename Q-5.js => Q5.js (100%) rename Q-6.js => Q6.js (100%) rename Q-7.js => Q7.js (100%) rename Q-8.js => Q8.js (100%) rename Q-9.js => Q9.js (100%) diff --git a/Q-1.js b/Q1.js similarity index 100% rename from Q-1.js rename to Q1.js diff --git a/Q-10.js b/Q10.js similarity index 100% rename from Q-10.js rename to Q10.js diff --git a/Q-11.js b/Q11.js similarity index 100% rename from Q-11.js rename to Q11.js diff --git a/Q-12.js b/Q12.js similarity index 100% rename from Q-12.js rename to Q12.js diff --git a/Q-13.js b/Q13.js similarity index 100% rename from Q-13.js rename to Q13.js diff --git a/Q-2.js b/Q2.js similarity index 100% rename from Q-2.js rename to Q2.js diff --git a/Q-3.js b/Q3.js similarity index 100% rename from Q-3.js rename to Q3.js diff --git a/Q-4.js b/Q4.js similarity index 100% rename from Q-4.js rename to Q4.js diff --git a/Q-5.js b/Q5.js similarity index 100% rename from Q-5.js rename to Q5.js diff --git a/Q-6.js b/Q6.js similarity index 100% rename from Q-6.js rename to Q6.js diff --git a/Q-7.js b/Q7.js similarity index 100% rename from Q-7.js rename to Q7.js diff --git a/Q-8.js b/Q8.js similarity index 100% rename from Q-8.js rename to Q8.js diff --git a/Q-9.js b/Q9.js similarity index 100% rename from Q-9.js rename to Q9.js