diff --git a/javascripting/accessing-array-values.js b/javascripting/accessing-array-values.js new file mode 100644 index 0000000..ee7d2a5 --- /dev/null +++ b/javascripting/accessing-array-values.js @@ -0,0 +1,3 @@ +var food = ['apple', 'pizza', 'pear']; + +console.log(food[1]); diff --git a/javascripting/array-filtering.js b/javascripting/array-filtering.js new file mode 100644 index 0000000..b310447 --- /dev/null +++ b/javascripting/array-filtering.js @@ -0,0 +1,7 @@ +var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + +var filtered = numbers.filter(function(numbers){ + return numbers % 2 === 0; +}); + +console.log(filtered); diff --git a/javascripting/arrays.js b/javascripting/arrays.js new file mode 100644 index 0000000..65f641b --- /dev/null +++ b/javascripting/arrays.js @@ -0,0 +1,3 @@ +var pizzaToppings = ['tomato sauce', 'cheese', 'pepperoni']; + +console.log(pizzaToppings); diff --git a/javascripting/for-loop.js b/javascripting/for-loop.js new file mode 100644 index 0000000..a6ef277 --- /dev/null +++ b/javascripting/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); diff --git a/javascripting/function-arguments.js b/javascripting/function-arguments.js new file mode 100644 index 0000000..2264084 --- /dev/null +++ b/javascripting/function-arguments.js @@ -0,0 +1,5 @@ +function math(num1, num2, num3){ + return num2 * num3 + num1; +} + +console.log(math(53, 61, 67)); diff --git a/javascripting/functions.js b/javascripting/functions.js new file mode 100644 index 0000000..e4928e2 --- /dev/null +++ b/javascripting/functions.js @@ -0,0 +1,5 @@ +function eat(food){ + return food + ' tasted really good.'; +} + +console.log(eat('bananas')); diff --git a/javascripting/if-statement.js b/javascripting/if-statement.js new file mode 100644 index 0000000..0990760 --- /dev/null +++ b/javascripting/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 has five characters or less.') +} diff --git a/javascripting/introduction.js b/javascripting/introduction.js new file mode 100644 index 0000000..bb00a5b --- /dev/null +++ b/javascripting/introduction.js @@ -0,0 +1 @@ +console.log('hello'); diff --git a/javascripting/looping-through-arrays.js b/javascripting/looping-through-arrays.js new file mode 100644 index 0000000..c5b7a70 --- /dev/null +++ b/javascripting/looping-through-arrays.js @@ -0,0 +1,7 @@ +var pets = ['cat', 'dog', 'rat']; + +for (var i = 0; i < pets.length; i++){ + pets[i] = pets[i] + 's'; +} + +console.log(pets); diff --git a/javascripting/number-to-string.js b/javascripting/number-to-string.js new file mode 100644 index 0000000..d66288c --- /dev/null +++ b/javascripting/number-to-string.js @@ -0,0 +1,4 @@ +var n = 128; +n = n.toString(); + +console.log(n); diff --git a/javascripting/numbers.js b/javascripting/numbers.js new file mode 100644 index 0000000..f82eb87 --- /dev/null +++ b/javascripting/numbers.js @@ -0,0 +1,3 @@ +var example = 123456789; + +console.log(example); diff --git a/javascripting/object-properties.js b/javascripting/object-properties.js new file mode 100644 index 0000000..7dfb707 --- /dev/null +++ b/javascripting/object-properties.js @@ -0,0 +1,5 @@ +var food = { + types: 'only pizza' +}; + +console.log(food.types); diff --git a/javascripting/objects.js b/javascripting/objects.js new file mode 100644 index 0000000..1ed4c33 --- /dev/null +++ b/javascripting/objects.js @@ -0,0 +1,7 @@ +var pizza = { + toppings: ['cheese', 'sauce', 'pepperoni'], + crust: 'deep dish', + serves: 2 +}; + +console.log(pizza); diff --git a/javascripting/revising-strings.js b/javascripting/revising-strings.js new file mode 100644 index 0000000..0a4da51 --- /dev/null +++ b/javascripting/revising-strings.js @@ -0,0 +1,5 @@ +var pizza = 'pizza is alright'; + +pizza = pizza.replace('alright', 'wonderful'); + +console.log(pizza); diff --git a/javascripting/rounding-numbers.js b/javascripting/rounding-numbers.js new file mode 100644 index 0000000..680b073 --- /dev/null +++ b/javascripting/rounding-numbers.js @@ -0,0 +1,5 @@ +var roundUp = 1.5; + +rounded = Math.round(roundUp); + +console.log(rounded); diff --git a/javascripting/scope.js b/javascripting/scope.js new file mode 100644 index 0000000..4cb3337 --- /dev/null +++ b/javascripting/scope.js @@ -0,0 +1,18 @@ +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; + })(); + })(); + })(); + })(); diff --git a/javascripting/string-length.js b/javascripting/string-length.js new file mode 100644 index 0000000..9f2cdf4 --- /dev/null +++ b/javascripting/string-length.js @@ -0,0 +1,3 @@ +example = 'example string'; + +console.log(example.length); diff --git a/javascripting/strings.js b/javascripting/strings.js new file mode 100644 index 0000000..5eae2fb --- /dev/null +++ b/javascripting/strings.js @@ -0,0 +1,3 @@ +var someString = 'this is a string'; + +console.log(someString); diff --git a/javascripting/variable.js b/javascripting/variable.js new file mode 100644 index 0000000..45b36f0 --- /dev/null +++ b/javascripting/variable.js @@ -0,0 +1,3 @@ +var example = 'some string'; + +console.log(example);