diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..4be84f3 Binary files /dev/null and b/.DS_Store differ diff --git a/accessing-array-values.js b/accessing-array-values.js new file mode 100644 index 0000000..b1875d6 --- /dev/null +++ b/accessing-array-values.js @@ -0,0 +1,2 @@ +var food = ['apple', 'pizza', 'pear']; +console.log(food[1]); \ No newline at end of file diff --git a/array-filtering.js b/array-filtering.js new file mode 100644 index 0000000..c4496ab --- /dev/null +++ b/array-filtering.js @@ -0,0 +1,8 @@ +var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +var filtered = numbers.filter(evenNumbers); + +function evenNumbers (number) { + return number % 2 === 0; +} + +console.log(filtered); diff --git a/arrays.js b/arrays.js new file mode 100644 index 0000000..9eb1ab2 --- /dev/null +++ b/arrays.js @@ -0,0 +1,2 @@ +var pizzaToppings = ['tomato sauce', 'cheese', 'pepperoni']; +console.log(pizzaToppings); \ No newline at end of file diff --git a/for-loop.js b/for-loop.js new file mode 100644 index 0000000..9ddae75 --- /dev/null +++ b/for-loop.js @@ -0,0 +1,8 @@ +var total = 0; +var limit = 10; + +for (var i = 0; i < limit; i++) { + total += i; +} + +console.log(total); \ No newline at end of file diff --git a/function-arguments.js b/function-arguments.js new file mode 100644 index 0000000..1b1404b --- /dev/null +++ b/function-arguments.js @@ -0,0 +1,5 @@ +function math(input1, input2, input3){ + return input1 + (input2 * input3); +}; + +console.log(math(53, 61, 67)); \ No newline at end of file diff --git a/functions.js b/functions.js new file mode 100644 index 0000000..eee7f06 --- /dev/null +++ b/functions.js @@ -0,0 +1,5 @@ +function eat(food){ + return food + ' tasted really good.'; +}; + +console.log(eat('bananas')); \ No newline at end of file diff --git a/if-statement.js b/if-statement.js new file mode 100644 index 0000000..1be0eea --- /dev/null +++ b/if-statement.js @@ -0,0 +1,8 @@ +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.') +}; \ No newline at end of file diff --git a/introduction.js b/introduction.js new file mode 100644 index 0000000..ea17b22 --- /dev/null +++ b/introduction.js @@ -0,0 +1 @@ +console.log('hello'); \ No newline at end of file diff --git a/looping-through-arrays.js b/looping-through-arrays.js new file mode 100644 index 0000000..aa54e62 --- /dev/null +++ b/looping-through-arrays.js @@ -0,0 +1,8 @@ +var pets = ['cat', 'dog', 'rat']; +var totalPets = pets.length; + +for (var counter = 0; counter < totalPets; counter++) { + pets[counter] = pets[counter] + 's'; +}; + +console.log(pets); \ No newline at end of file diff --git a/number-to-string.js b/number-to-string.js new file mode 100644 index 0000000..e8e6206 --- /dev/null +++ b/number-to-string.js @@ -0,0 +1,3 @@ +var n = 128; + +console.log(n.toString()); \ No newline at end of file diff --git a/numbers.js b/numbers.js new file mode 100644 index 0000000..7234a07 --- /dev/null +++ b/numbers.js @@ -0,0 +1,2 @@ +var example = 123456789; +console.log(examples); \ No newline at end of file diff --git a/object-properties.js b/object-properties.js new file mode 100644 index 0000000..1dba17f --- /dev/null +++ b/object-properties.js @@ -0,0 +1,5 @@ +var food = { + types: 'only pizza' +}; + +console.log(food.types); \ No newline at end of file diff --git a/objects.js b/objects.js new file mode 100644 index 0000000..01f536d --- /dev/null +++ b/objects.js @@ -0,0 +1,7 @@ +var pizza = { + toppings: ['cheese', 'sauce', 'pepperoni'], + crust: 'deep dish', + serves: 2 +} + +console.log(pizza); \ No newline at end of file diff --git a/revising-strings.js b/revising-strings.js new file mode 100644 index 0000000..739bf9b --- /dev/null +++ b/revising-strings.js @@ -0,0 +1,3 @@ +var pizza = 'pizza is alright'; +pizza = pizza.replace('alright', 'wonderful'); +console.log(pizza); \ No newline at end of file diff --git a/rounding-numbers.js b/rounding-numbers.js new file mode 100644 index 0000000..03c8566 --- /dev/null +++ b/rounding-numbers.js @@ -0,0 +1,5 @@ +var roundUp = 1.5; + +var rounded = Math.round(roundUp); + +console.log(rounded); \ No newline at end of file diff --git a/scope.js b/scope.js new file mode 100644 index 0000000..0820db9 --- /dev/null +++ b/scope.js @@ -0,0 +1,19 @@ +var a = 1, b = 2, c = 3; + +(function firstFunction(){ + var b = 5, c = 6; + + (function secondFunction(){ + var b = 8; + console.log("a: "+a+", b: "+b+",c: "+c); + + (function thirdFunction(){ + var a = 7, c = 9; + + (function fourthFunction(){ + var a = 1, c = 8; + + })(); + })(); + })(); +})(); \ No newline at end of file diff --git a/string-length.js b/string-length.js new file mode 100644 index 0000000..a0d32b6 --- /dev/null +++ b/string-length.js @@ -0,0 +1,2 @@ +var example = 'example string'; +console.log(example.length); \ No newline at end of file diff --git a/strings.js b/strings.js new file mode 100644 index 0000000..9483a4a --- /dev/null +++ b/strings.js @@ -0,0 +1,2 @@ +var someString = 'this is a string'; +console.log(someString); \ No newline at end of file diff --git a/variables.js b/variables.js new file mode 100644 index 0000000..06bc2b0 --- /dev/null +++ b/variables.js @@ -0,0 +1,2 @@ +var example = 'some string'; +console.log(example); \ No newline at end of file