-
Notifications
You must be signed in to change notification settings - Fork 10
Week6 Homework Submission #2
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
base: Hamza-Koc
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
|
|
||
| //1.Write a console.log statement saying "Hello World!" for each language that you know. | ||
| console.log('Hello World!'); // English | ||
| console.log('Merhaba Dunya!'); //Turkish | ||
| console.log('Marhaba Dunia!') //Zazaki | ||
|
|
||
|
|
||
| //2.Consider the following code: | ||
| console.log('I\'m awesome'); | ||
|
|
||
| //3.Declare a variable age and initialize it with an integer, using these exact steps: | ||
| let x; | ||
| console.log('the value of age will be: 30'); | ||
| console.log(x); | ||
| x=30; | ||
| console.log('the value of age will be: 30'); | ||
| console.log(x); | ||
|
|
||
| //4.Declare a variable name and assign a string to it. | ||
|
|
||
| let y ='butterfly'; | ||
| console.log('the value of my string will be:bird'); | ||
|
Collaborator
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. Maybe you made a typo, but the value of |
||
| console.log(y); | ||
| y='bird'; | ||
| console.log('the value of my string will be:bird'); | ||
| console.log(y); | ||
|
|
||
|
|
||
| //5.How do you round the number 7.25, to the nearest integer (i.e., whole number)? | ||
|
|
||
| let number=7.25; | ||
| console.log(number);// prints 7.25 | ||
|
|
||
| let roundedNumber=Math.round(number); | ||
| console.log(number); // prints 7 | ||
|
|
||
| if(roundedNumber < number){ | ||
|
Collaborator
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. Good work here, but make sure you declare your variable |
||
| result=roundedNumber; | ||
| } | ||
| else{ | ||
| result=number; | ||
| } | ||
| console.log(result); | ||
|
|
||
|
|
||
| //6.Arrays | ||
|
|
||
| let colors=[]; | ||
| console.log('the value of my array is: blue, yellow, green, black'); | ||
|
Collaborator
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. Did you forget to add some colors to your array? |
||
| console.log(colors); | ||
|
|
||
| let myFavoriteAnimals=['rabbit', 'cat', 'bird', 'dog']; | ||
| console.log(myFavoriteAnimals); | ||
| myFavoriteAnimals.push('kitten'); | ||
| console.log(myFavoriteAnimals); | ||
|
|
||
|
|
||
| //7.More strings: Let's consider the following string: let myString = "this is a test". | ||
|
|
||
| let myString = "this is a test"; | ||
| console.log(myString); | ||
| console.log(myString.length); | ||
|
|
||
|
|
||
| //8.If x equals 7, and the only other statement is x = x % 3, what would be the new value of x? | ||
|
Collaborator
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. Good job with the examples here! |
||
|
|
||
| x = 7; | ||
| x = x % 3; | ||
| console.log(x); | ||
|
|
||
| y=15; | ||
| y=y % 5; | ||
| console.log('remainer is 0 from 15 /5'); | ||
|
|
||
| z=20; | ||
| z=z % 6; | ||
| console.log('remainer is 2 from 20 /6'); | ||
|
|
||
|
|
||
|
|
||
| //9.Write a program to answer the following questions: | ||
|
|
||
| let numberString=[1,2,3,'hamza', 'yunus',true,]; | ||
| console.log(numberString); | ||
| console.log('we can store multiple types in an array with their special signs ex: string must be between \'\' or \"\".') | ||
|
|
||
| console.log(6/0===10/0); | ||
| console.log('3 equals compare two values if they are same values and types.') | ||
|
|
||
|
|
||
|
|
||
| //10.I’ve declared a multidimensional array (an array inside an array) -- see below. How can I access the third item’s second element? i.e. [2, 1] is the third element, and I want to access 1. Add a console.log statement accessing this item. | ||
|
|
||
| const grid = [[0, 1], [1, 1], [2, 1], [3, 1]]; | ||
| console.log(grid[2][1]); | ||
|
|
||
|
|
||
|
|
||
| //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; | ||
| console.log('first method'); | ||
| console.log(counter + 2); | ||
|
|
||
|
|
||
| counter=+2; | ||
|
Collaborator
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.
|
||
| console.log('Second method'); | ||
| console.log(counter); | ||
|
|
||
|
|
||
| counter+=2; | ||
| console.log('third method'); | ||
|
|
||
|
|
||
| //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 breed ='Domestik Shorthair'; | ||
| const color ='Orange or Red Tabby'; | ||
| const age = '1 year old'; | ||
| const sex = 'Male'; | ||
| const hair ='Short'; | ||
| const info=['Neutered', 'Good with Kids', 'Shots Up to Date', 'Good with Cats']; | ||
| const aboutStory=['facebook', 'twitter', 'pinterest', 'email']; | ||
| const date='july 28,2018'; | ||
| console.log(name+' is '+info+'his best friend is '+bestFriend+' He is '+age+' and has '+ hair+ 'hair'); | ||
|
|
||
|
|
||
| //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 kittens=['Kyle Meowry', 'Luna', 'Obi','Charlie', 'Raspberries']; | ||
| let adults=['Mezzo', 'Sabrina', 'josie']; | ||
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.
After you ran your program, do you understand why
xisn't 30 when you first declared it on line 12?