From cc9186748d7eb9ef7f94b5ef9d5d4a98d5a879f4 Mon Sep 17 00:00:00 2001 From: alinjo Date: Mon, 23 Sep 2024 14:48:56 +0200 Subject: [PATCH 1/3] Finished assignment.js and decleration.js --- .husky/pre-commit | 4 ---- src/assignment.js | 5 ++++- src/declaration.js | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 6b54e0b..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx eslint src diff --git a/src/assignment.js b/src/assignment.js index a2f2b63..8f5bc83 100644 --- a/src/assignment.js +++ b/src/assignment.js @@ -3,9 +3,12 @@ let firstNumber = 10 firstNumber = 0 // TODO: 1. Set the value of firstNumber below so the tests pass +firstNumber = 20 // TODO: 2. Change the code below so that the tests pass -const secondNumber = 0 // edit this value +const secondNumber = 42 // edit this value +console.log(firstNumber) +console.log(secondNumber) // do not edit the exported object. module.exports = { diff --git a/src/declaration.js b/src/declaration.js index 80daf64..c170b37 100644 --- a/src/declaration.js +++ b/src/declaration.js @@ -2,6 +2,10 @@ // // // TODO: 1. Declare the variables firstName and age so that the tests pass +const firstName = 'Jane' +const age = 35 +console.log(firstName) +console.log(age) // do not edit below this line let firstNameExport = '' From 5dbce0d600a9f6c2c00099b45dfdd05ecf1290a0 Mon Sep 17 00:00:00 2001 From: alinjo Date: Mon, 23 Sep 2024 15:23:01 +0200 Subject: [PATCH 2/3] Finished assignment.js and decleration.js and extension --- src/extensions/types.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/extensions/types.js b/src/extensions/types.js index ce48367..853e741 100644 --- a/src/extensions/types.js +++ b/src/extensions/types.js @@ -35,34 +35,34 @@ function pick(n) { } // 1. Pick true using the pick function - by changing 0 to pick your answer -const imTrue = pick(0) +const imTrue = pick(9) // 2. Pick a real number -const aReal = pick(0) +const aReal = pick(4) // 3. Pick a string -const aString = pick(3) +const aString = pick(6) // 4. Pick an array -const anArray = pick(1) +const anArray = pick(7) // 5. Pick a (simple) number -const aNumber = pick(0) +const aNumber = pick(3) // 6. Pick an object -const anObject = pick(1) +const anObject = pick(8) // 7. Pick false -const imFalse = pick(0) +const imFalse = pick(10) // 8. Pick a BigInt -const imBigInt = pick(1) +const imBigInt = pick(5) // 9. Pick undefined -const imUndefined = pick(0) +const imUndefined = pick(2) // 10. Pick null -const imNull = pick(0) +const imNull = pick(1) // Do not edit below this line module.exports = { From 6fabfe8502138790fa70563da433224853a214a4 Mon Sep 17 00:00:00 2001 From: alinjo Date: Mon, 23 Sep 2024 15:42:39 +0200 Subject: [PATCH 3/3] Finished assignment.js and decleration.js and extension and advanced --- .github/workflows/run-extensions-tests.yml | 2 +- .github/workflows/run-tests.yml | 2 +- spec/support/all-jasmine.json | 19 +++++++------------ spec/support/extensions-jasmine.json | 19 +++++++------------ src/README.md | 14 +++++++------- src/advanced/swap.js | 1 + 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/.github/workflows/run-extensions-tests.yml b/.github/workflows/run-extensions-tests.yml index c8b6d7f..d84b869 100644 --- a/.github/workflows/run-extensions-tests.yml +++ b/.github/workflows/run-extensions-tests.yml @@ -1,7 +1,7 @@ name: JS Fundamentals Variables Extensions Tests on: pull_request: - branches: [ main ] + branches: [main] jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 014245b..d70011d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,7 +1,7 @@ name: JS Fundamentals Variables Tests on: pull_request: - branches: [ main ] + branches: [main] jobs: build: runs-on: ubuntu-latest diff --git a/spec/support/all-jasmine.json b/spec/support/all-jasmine.json index 24f0083..4d2193b 100644 --- a/spec/support/all-jasmine.json +++ b/spec/support/all-jasmine.json @@ -1,14 +1,9 @@ { - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.?(m)js" - ], - "helpers": [ - "helpers/**/*.?(m)js" - ], - "env": { - "stopSpecOnExpectationFailure": false, - "random": true - } + "spec_dir": "spec", + "spec_files": ["**/*[sS]pec.?(m)js"], + "helpers": ["helpers/**/*.?(m)js"], + "env": { + "stopSpecOnExpectationFailure": false, + "random": true } - \ No newline at end of file +} diff --git a/spec/support/extensions-jasmine.json b/spec/support/extensions-jasmine.json index d41afa2..aa1ae9b 100644 --- a/spec/support/extensions-jasmine.json +++ b/spec/support/extensions-jasmine.json @@ -1,14 +1,9 @@ { - "spec_dir": "spec", - "spec_files": [ - "extensions/**/*[sS]pec.?(m)js" - ], - "helpers": [ - "helpers/**/*.?(m)js" - ], - "env": { - "stopSpecOnExpectationFailure": false, - "random": true - } + "spec_dir": "spec", + "spec_files": ["extensions/**/*[sS]pec.?(m)js"], + "helpers": ["helpers/**/*.?(m)js"], + "env": { + "stopSpecOnExpectationFailure": false, + "random": true } - \ No newline at end of file +} diff --git a/src/README.md b/src/README.md index f7ed613..37027cb 100644 --- a/src/README.md +++ b/src/README.md @@ -4,19 +4,19 @@ Variables are used to store values. Before a variable can be used, it must be ** > 👨‍💻 Run these examples in your REPL as you read along! 👨‍💻 - In JavaScript, we can declare variables using the `const` keyword. The below code declares a variable called `name`, and sets the value to "Jane": +In JavaScript, we can declare variables using the `const` keyword. The below code declares a variable called `name`, and sets the value to "Jane": ```javascript -const name='Jane' +const name = 'Jane' ``` Variables that are declared using `const` cannot change their value - their value is **constant** (try change it and see what happens!). The `let` keyword can be used to declare a variable that can change value: ```javascript -let otherName='Jane' +let otherName = 'Jane' //We can now assign a new value to name -otherName='Bob' +otherName = 'Bob' ``` In Javascript, any valid data type can be stored in a variable. The above example created a variable that stored a `string` data type. `string` values are always enclosed in quotes. Numbers can be stored in variables too: @@ -34,10 +34,10 @@ const firstName = 'Jane' ## Next Work your way through the tests for this section. You can use the references below and also -the `example.js` file to see more code samples. Remember you can make use of the Node REPL +the `example.js` file to see more code samples. Remember you can make use of the Node REPL to try out and experiment with code. ## References -* [Boolean Variables Slides](https://docs.google.com/presentation/d/17blHGDVfjN_EerQtw0ybFDtJEhjj9wAU9qHoI1DAnYw/edit?usp=sharing) -* [MDN Declaring Variables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#declarations) +- [Boolean Variables Slides](https://docs.google.com/presentation/d/17blHGDVfjN_EerQtw0ybFDtJEhjj9wAU9qHoI1DAnYw/edit?usp=sharing) +- [MDN Declaring Variables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#declarations) diff --git a/src/advanced/swap.js b/src/advanced/swap.js index 7908a03..914f4cb 100644 --- a/src/advanced/swap.js +++ b/src/advanced/swap.js @@ -2,5 +2,6 @@ let a = 8 let b = 10 // TODO: Swap the values of a and b without changing lines 1 and 2; extra points if you can do it without using a temporary variable +;[a, b] = [b, a] module.exports = { a, b }