-
Notifications
You must be signed in to change notification settings - Fork 31
Complete exercise #3
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: master
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,2 @@ | ||
| var food = ['apple', 'pizza', 'pear']; | ||
| console.log(food[1]); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
| var filtered = numbers.filter( function evenNumbers(number) { | ||
| return number % 2 === 0; | ||
| }); | ||
| console.log(filtered); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| var pizzaToppings = ['tomato sauce', 'cheese', 'pepperoni']; | ||
| console.log(pizzaToppings); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| var total = 0; | ||
| var limit = 10; | ||
| for (var i = 0; i < limit; i++){ | ||
| total += i; | ||
| } | ||
| console.log(total); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| function math (a, b, c) { | ||
| return b*c+a; | ||
| } | ||
| console.log(math(53, 61, 67)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| function eat (food) { | ||
| return food + ' tasted really good.'; | ||
| } | ||
| console.log(eat('bananas')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| var fruit = 'orange'; | ||
| if (fruit.length > 5) { | ||
| console.log('The fruit name has more than five characters.'); | ||
| } else { | ||
| console.log('The fruit name has five characters or less.'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log('hello'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| var pets = ['cat', 'dog', 'rat']; | ||
| for (var i = 0; i < pets.length; i++) { | ||
|
Member
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. what would be the benefit of maybe doing the following instead? |
||
| pets[i] = pets[i] + 's'; | ||
| } | ||
| console.log(pets); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| var n = 128; | ||
| n = n.toString(); | ||
| console.log(n); | ||
|
Member
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. nice. you could also write this as |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| example = 123456789; | ||
|
Member
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. always |
||
| console.log(example); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| var foods = { | ||
| types: 'only pizza' | ||
| } | ||
| console.log(foods.types); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| var pizza = { | ||
| toppings: ['cheese', 'sauce', 'pepperoni'], | ||
| crust: 'deep dish', | ||
| serves: 2 | ||
| } | ||
| console.log(pizza); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| var pizza = 'pizza is alright'; | ||
| pizza = pizza.replace('alright', 'wonderful'); | ||
| console.log(pizza); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| var roundUp = 1.5; | ||
| var rounded = Math.round(roundUp); | ||
| console.log(rounded); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| var example = 'example string'; | ||
| console.log(example.length); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| var someString = 'this is a string'; | ||
| console.log(someString); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| var example = 'some string'; | ||
| console.log(example); |
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.
its not a problem but you don't have to name your callback function here if you dont want.