diff --git a/accessing-array-values.js b/accessing-array-values.js new file mode 100644 index 0000000..e7895b5 --- /dev/null +++ b/accessing-array-values.js @@ -0,0 +1,2 @@ +const 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..701a7c4 --- /dev/null +++ b/array-filtering.js @@ -0,0 +1,3 @@ +const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +const filtered = numbers.filter((number) => number % 2 == 0) +console.log(filtered) \ No newline at end of file diff --git a/arrays.js b/arrays.js new file mode 100644 index 0000000..b8b02ba --- /dev/null +++ b/arrays.js @@ -0,0 +1,2 @@ +const 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..443b411 --- /dev/null +++ b/for-loop.js @@ -0,0 +1,5 @@ +let total = 0 +const limit = 10 +for (let 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..8d8add4 --- /dev/null +++ b/function-arguments.js @@ -0,0 +1,5 @@ +function math (a, b, c) { + return b * c + a +} + +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..5a8bf9f --- /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..3527619 --- /dev/null +++ b/if-statement.js @@ -0,0 +1,3 @@ +const fruit = "orange" +console.log(fruit.length > 5 ? "The fruit name has more than five characters." : + "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..371fdfb --- /dev/null +++ b/introduction.js @@ -0,0 +1 @@ +console.log('hello') diff --git a/looping-through-arrays.js b/looping-through-arrays.js new file mode 100644 index 0000000..980e949 --- /dev/null +++ b/looping-through-arrays.js @@ -0,0 +1,4 @@ +const pets = ['cat', 'dog', 'rat'] +for (let i = 0; i < pets.length; i++) + pets[i] = pets[i] + '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..b4a608f --- /dev/null +++ b/number-to-string.js @@ -0,0 +1,2 @@ +const 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..f6d3f51 --- /dev/null +++ b/numbers.js @@ -0,0 +1,2 @@ +const example = 123456789 +console.log(example) \ No newline at end of file diff --git a/object-keys.js b/object-keys.js new file mode 100644 index 0000000..4a7341c --- /dev/null +++ b/object-keys.js @@ -0,0 +1,7 @@ +const car = { + make: 'Honda', + model: 'Accord', + year: 2020 + } +const keys = Object.keys(car) +console.log(keys) \ No newline at end of file diff --git a/object-properties.js b/object-properties.js new file mode 100644 index 0000000..7df39a1 --- /dev/null +++ b/object-properties.js @@ -0,0 +1,4 @@ +const 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..6500c29 --- /dev/null +++ b/objects.js @@ -0,0 +1,6 @@ +const 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..fc6d143 --- /dev/null +++ b/revising-strings.js @@ -0,0 +1,2 @@ +const pizza = 'pizza is alright' +console.log(pizza.replace('alright','wonderful')) \ No newline at end of file diff --git a/rounding-numbers.js b/rounding-numbers.js new file mode 100644 index 0000000..ddd0a8f --- /dev/null +++ b/rounding-numbers.js @@ -0,0 +1,3 @@ +const roundUp = 1.5 +const 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..63739f0 --- /dev/null +++ b/scope.js @@ -0,0 +1,18 @@ +const a = 1; const b = 2; const c = 3; + + (function firstFunction () { + const b = 5; const c = 6; + + (function secondFunction () { + const b = 8; + + (function thirdFunction () { + const a = 7; const c = 9; + + (function fourthFunction () { + const a = 1; const c = 8 + })() + })() + console.log(`a: ${a}, b: ${b}, c: ${c}`) + })() + })() \ No newline at end of file diff --git a/string-length.js b/string-length.js new file mode 100644 index 0000000..77bf197 --- /dev/null +++ b/string-length.js @@ -0,0 +1,2 @@ +const 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..1506ba0 --- /dev/null +++ b/strings.js @@ -0,0 +1,2 @@ +const 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..ac1b604 --- /dev/null +++ b/variables.js @@ -0,0 +1,2 @@ +const example = 'some string' +console.log(example) \ No newline at end of file