Skip to content
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

Ali Ehsani-Yeganeh #292

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-extensions-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: JS Fundamentals Variables Extensions Tests
on:
pull_request:
branches: [ main ]
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: JS Fundamentals Variables Tests
on:
pull_request:
branches: [ main ]
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
Expand Down
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

19 changes: 7 additions & 12 deletions spec/support/all-jasmine.json
Original file line number Diff line number Diff line change
@@ -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
}
}
19 changes: 7 additions & 12 deletions spec/support/extensions-jasmine.json
Original file line number Diff line number Diff line change
@@ -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
}
}
14 changes: 7 additions & 7 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
1 change: 1 addition & 0 deletions src/advanced/swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
5 changes: 4 additions & 1 deletion src/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 4 additions & 0 deletions src/declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
20 changes: 10 additions & 10 deletions src/extensions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading