Skip to content
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
4 changes: 4 additions & 0 deletions Q1.js
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Q10.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 4 additions & 0 deletions Q11.js
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are two ways to increment the variable, and the third way would be

counter +=2 // short way of writing counter = counter + 2;

10 changes: 10 additions & 0 deletions Q12.js
Original file line number Diff line number Diff line change
@@ -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';
4 changes: 4 additions & 0 deletions Q13.js
Original file line number Diff line number Diff line change
@@ -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!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the information we want to store is a list of things (names of cats), we should use an array (with the square brackets []).

let nameAdult = ['Mezzo','Sabrina','Josie'];
let nameKitten = ['Kyle Meowry','Luna','Obi','Charlie','Raspberries'];


let nameAdult = 'Mezzo','Sabrina','Josie';
let nameKitten = 'Kyle Meowry','Luna','Obi','Charlie','Raspberries';
6 changes: 6 additions & 0 deletions Q2.js
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right!

// w3school "You can use quotes inside a string, as long as they don't match the quotes surrounding the string:"
9 changes: 9 additions & 0 deletions Q3.js
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instructions might have been unclear - they were asking you to explain what you think the value of age is before you initialize it.

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.
11 changes: 11 additions & 0 deletions Q4.js
Original file line number Diff line number Diff line change
@@ -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);
16 changes: 16 additions & 0 deletions Q5.js
Original file line number Diff line number Diff line change
@@ -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);
14 changes: 14 additions & 0 deletions Q6.js
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions Q7.js
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 5 additions & 0 deletions Q8.js
Original file line number Diff line number Diff line change
@@ -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);
13 changes: 13 additions & 0 deletions Q9.js
Original file line number Diff line number Diff line change
@@ -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?');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after running the comparison on line 12, do you have an answer?

// 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).