-
Notifications
You must be signed in to change notification settings - Fork 10
week6 homework done #11
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
Open
esyasar
wants to merge
1
commit into
hackyourfuturecanada:Elif-Sude-Yasar
Choose a base branch
from
esyasar:master
base: Elif-Sude-Yasar
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| //ELif Sude Yasar | ||
|
|
||
| // 1. Write a console.log statement saying "Hello World!" for each language that you know. | ||
| console.log('Merhaba Dunya'); //Turkish | ||
| console.log('Hello World'); //English | ||
| console.log('Hallo Welt'); //German | ||
|
|
||
| // 2. // Consider the following code: | ||
| // console.log('I'm awesome'); | ||
| // Copy the code in your .js file and run it. You will see that you will get a SyntaxError. Find a solution for this error. Hint: read the error message carefully, it also gives an indication of where the problem is. | ||
|
|
||
| console.log('I\'m awesome'); | ||
|
|
||
| // 3.Declare a variable age and initialize it with an integer, using these exact steps: | ||
| let age; | ||
| console.log("'the value of age will be: undefined'"); | ||
| console.log(age); | ||
| age = 19; | ||
| console.log("'the value of age will be: 19'"); | ||
| console.log(age); | ||
|
|
||
|
|
||
| //4.Declare a variable name and assign a string to it. | ||
|
|
||
| let name; | ||
| console.log("The value of name will be undefined because I didn't initialize it.") | ||
| console.log(name); | ||
| name = "Elif Sude Yasar"; | ||
| console.log("The value of name will be Elif Sude Yasar") | ||
| console.log(name); | ||
|
|
||
|
|
||
| //5.How do you round the number 7.25, to the nearest integer (i.e., whole number)? | ||
|
|
||
| var number; | ||
| number = "7.25"; | ||
| console.log(number); | ||
|
|
||
| var roundedNumber=Math.round(number); | ||
| console.log(roundedNumber); | ||
|
|
||
| let highest = Math.max(number, roundedNumber); | ||
| console.log(highest); | ||
|
|
||
|
|
||
| //6.Arrays | ||
|
|
||
| let animals; | ||
| console.log("The value of animals will be undefined"); | ||
| console.log(animals); | ||
|
|
||
| let favAnimals = ["panda", "cat", "rabbit"]; | ||
| console.log(favAnimals); | ||
| favAnimals.push("kitten"); | ||
| console.log(favAnimals); | ||
|
|
||
|
|
||
| //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? | ||
|
|
||
|
|
||
| var x = 7; | ||
| x = x % 3; | ||
| console.log(x); | ||
|
|
||
|
|
||
|
|
||
| var x = 7; | ||
| console.log(x % 3); | ||
|
|
||
|
|
||
| var x = 7; | ||
| var y = 3; | ||
| x = x % y; | ||
| console.log(x); | ||
|
|
||
| var x = 7; | ||
| var y = 3; | ||
| var result = x % y; | ||
| console.log(result); | ||
|
|
||
|
|
||
| //9.Write a program to answer the following questions: | ||
|
|
||
| let multiValue =["panda", 45 , "giraffe"]; | ||
| console.log(multiValue); | ||
|
|
||
|
|
||
| let comparison = 6/0===10/0; | ||
| console.log("The result is infinite"); | ||
| console.log(comparison); | ||
|
|
||
| let colors = ["blue", "red", "purple", 3, 4, 5]; | ||
| console.log(colors); | ||
| console.log(colors.length); | ||
|
|
||
|
|
||
| //10. How can I access the third item’s second element? i.e. | ||
|
|
||
| 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'); | ||
| counter +=2; | ||
| console.log(counter); | ||
|
|
||
| console.log('second method'); | ||
| counter = counter + 2; | ||
| console.log(counter); | ||
|
|
||
| console.log('third method'); | ||
| counter++; | ||
| counter++; | ||
| console.log(counter); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // Question 12 | ||
| const cat = { | ||
|
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. Great! |
||
| name: 'Prince', | ||
| bestFriend: 'Thomas', | ||
| breed: 'domestic shorthair', | ||
| age: '1 year old', | ||
| sex: 'male' | ||
| } | ||
| console.log(cat); | ||
|
|
||
|
|
||
| //Question 13 | ||
|
|
||
| let kittens = ["Kyle Meowry","Luna","Obi","Charlie","Raspberrries"]; | ||
| let adultCats = ["Mezzo","Sabrina","Josie"]; | ||
|
|
||
| console.log(kittens, adultCats); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's great you added an explanation here.