diff --git a/.github/workflows/extension-criteria-tests.yml b/.github/workflows/extension-criteria-tests.yml index 48bbfa1..9e7cc56 100644 --- a/.github/workflows/extension-criteria-tests.yml +++ b/.github/workflows/extension-criteria-tests.yml @@ -1,7 +1,7 @@ name: Extension Criteria on: pull_request: - branches: [ main ] + branches: [main] jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/standard-criteria-tests.yml b/.github/workflows/standard-criteria-tests.yml index ca418bc..6023e31 100644 --- a/.github/workflows/standard-criteria-tests.yml +++ b/.github/workflows/standard-criteria-tests.yml @@ -1,7 +1,7 @@ name: Standard Criteria on: pull_request: - branches: [ main ] + branches: [main] jobs: build: runs-on: ubuntu-latest diff --git a/spec/extensions/extension-1.spec.js b/spec/extensions/extension-1.spec.js index 9797a9c..ba70453 100644 --- a/spec/extensions/extension-1.spec.js +++ b/spec/extensions/extension-1.spec.js @@ -1,19 +1,19 @@ const { a, b, c, d } = require('../../src/extensions/example.js') describe('Example [Extensions]', () => { - it( "Check null", () => { - expect(a).toBe("null"); + it('Check null', () => { + expect(a).toBe('null') }) - it( "Check undefined", () => { - expect(b).toBe("undefined"); + it('Check undefined', () => { + expect(b).toBe('undefined') }) - it( "Check true", () => { - expect(c).toBe("boolean"); + it('Check true', () => { + expect(c).toBe('boolean') }) - it( "Check false", () => { - expect(d).toBe("boolean"); + it('Check false', () => { + expect(d).toBe('boolean') }) }) diff --git a/spec/extensions/more-data-types.spec.js b/spec/extensions/more-data-types.spec.js index c42e3f5..1f65077 100644 --- a/spec/extensions/more-data-types.spec.js +++ b/spec/extensions/more-data-types.spec.js @@ -1,25 +1,33 @@ -const { a, b, c, d, e, f, g } = require('../../src/extensions/more-data-types.js') +const { + a, + b, + c, + d, + e, + f, + g +} = require('../../src/extensions/more-data-types.js') describe('Example [Extensions]', () => { - it( "Check null", () => { - expect(a).toBe(null); + it('Check null', () => { + expect(a).toBe(null) }) - it( "Check true", () => { - expect(b).toBe(true); + it('Check true', () => { + expect(b).toBe(true) }) - it( "Check false", () => { - expect(c).toBe(false); + it('Check false', () => { + expect(c).toBe(false) }) - it( "Check undefined", () => { - expect(d).toBe(undefined); + it('Check undefined', () => { + expect(d).toBe(undefined) }) - it( "Check boolean", () => { - expect(e).toBe("boolean"); + it('Check boolean', () => { + expect(e).toBe('boolean') }) - it( "Check boolean", () => { - expect(f).toBe("boolean"); + it('Check boolean', () => { + expect(f).toBe('boolean') }) - it( "Check undefined", () => { - expect(g).toBe("undefined"); + it('Check undefined', () => { + expect(g).toBe('undefined') }) }) 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 ee2c046..3c4cb1d 100644 --- a/src/README.md +++ b/src/README.md @@ -1,4 +1,5 @@ # Data Types + From text and numbers to lists, people and actions, everything in JavaScript can be represented using data types. Here are the most important ones. **Primitive types**: These are units that cannot be broken down any further @@ -17,30 +18,30 @@ From text and numbers to lists, people and actions, everything in JavaScript can const isCodingFun = true ``` -There’s really not much we can do with a boolean by itself, yet, as we will see later on when we cover conditionals, they are crucial to programming. We usually get true or false as a result of asking our program a question. +There’s really not much we can do with a boolean by itself, yet, as we will see later on when we cover conditionals, they are crucial to programming. We usually get true or false as a result of asking our program a question. > 👨‍💻 Run these examples in your REPL as you read along! 👨‍💻 ```javascript -5 > 3 //Is 5 greater than 3? ->>> true +5 > + 3 >>> //Is 5 greater than 3? + true ``` ```javascript -5 > 10 //Is 5 greater than 10? ->>> false +5 > + 10 >>> //Is 5 greater than 10? + false ``` Booleans can be flipped by adding an exclamation mark right before it: ```javascript -!true ->>> false +!true >>> false ``` ```javascript -!false ->>> true +!false >>> true ``` ## Numbers @@ -54,28 +55,28 @@ As you might expect, anything that you can usually do with numbers you can do in > 👨‍💻 Run these examples in your REPL as you read along! 👨‍💻 ```javascript -10 + 10 //addition ->>> 20 -``` +;(10 + 10) >>> //addition + 20 +``` ```javascript -10 - 10 //subtraction ->>> 0 -``` +;(10 - 10) >>> //subtraction + 0 +``` ```javascript -10 * 10 //multiplication ->>> 100 -``` +;(10 * 10) >>> //multiplication + 100 +``` ```javascript -10 / 10 //division ->>> 1 -``` +;(10 / 10) >>> //division + 1 +``` ```javascript -24 % 5 // remainder of 24 / 5 ->>> 4 +24 % 5 >>> // remainder of 24 / 5 + 4 ``` The above examples all use literal values (i.e. a specific number), but we can also perform these operations with variables and store any result in a variable too: @@ -83,9 +84,8 @@ The above examples all use literal values (i.e. a specific number), but we can a ```javascript const price = 10 const quantity = 2 -const cost = price * quantity -console.log(price) ->>> 10 +const cost = price * quantity +console.log(price) >>> 10 ``` ## Strings @@ -101,9 +101,8 @@ Strings are simply how we represent text within our programs, from a single char In JavaScript, we can create a string by wrapping our characters in single , double quotes or backticks: ```javascript -"hey there!" 'hey there!' -`hey there!` +'hey there!'`hey there!` ``` We can add strings together by using the plus `+` operator. This is called **concatenation**. @@ -111,24 +110,20 @@ We can add strings together by using the plus `+` operator. This is called **con Run the below code exmaples in your REPL: ```javascript -'Hello' + 'there!' ->> 'Hellothere!' +;('Hello' + 'there!') >> 'Hellothere!' ``` We can also concatenate string variables: ```javascript const teacher = 'Nicolas' -'Hello ' + teacher + '!' ->>> 'Hello Nicolas!' +;('Hello ' + teacher + '!') >>> 'Hello Nicolas!' ``` Adding variables to a string is called interpolation, and you’ll be doing this a lot! We can also use strings wrapped in back quotes (or backticks) to achieve the same result. This code is equivalent to the above example: ```javascript -const teacherLiteral = 'Nicolas' -`Hello ${teacherLiteral} !` ->>> 'Hello Nicolas!' +const teacherLiteral = 'Nicolas'`Hello ${teacherLiteral} !` >>> 'Hello Nicolas!' ``` This is called a **template literal**. @@ -137,32 +132,30 @@ Strings also have a TON of useful helper methods and properties. Here’s a coup ```javascript const name = 'Nicolas' -name.length ->>> 7 +name.length >>> 7 ``` ```javascript const nameUpper = 'Nicolas' -nameUpper.toUpperCase() ->>> 'NICOLAS' +nameUpper.toUpperCase() >>> 'NICOLAS' ``` You can also extract a specific character from a string by using the square brackets syntax `string[index]`: ```javascript const hello = 'Hello' -hello[1] //the index is 0 based! This will return the 2nd character ->>> 'e' +hello[1] >>> //the index is 0 based! This will return the 2nd character + 'e' ``` ## 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) -* [Boolean Strings Slides](https://docs.google.com/presentation/d/1w_cS-TIrEfROoA-OPsC_AxAkdu-1BNkdqkEq-qroNsE/edit?usp=sharing) -* [MDN Data Types](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) +- [Boolean Variables Slides](https://docs.google.com/presentation/d/17blHGDVfjN_EerQtw0ybFDtJEhjj9wAU9qHoI1DAnYw/edit?usp=sharing) +- [Boolean Strings Slides](https://docs.google.com/presentation/d/1w_cS-TIrEfROoA-OPsC_AxAkdu-1BNkdqkEq-qroNsE/edit?usp=sharing) +- [MDN Data Types](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) diff --git a/src/extensions/more-data-types.js b/src/extensions/more-data-types.js index 64cde7b..093a58b 100644 --- a/src/extensions/more-data-types.js +++ b/src/extensions/more-data-types.js @@ -1,22 +1,22 @@ // TODO: Replace the empty string in the lines below using Javascript with the correct data types // 1. Set this variable to be null -const nullVariable = '' +const nullVariable = null // 2. Set this variable to be true -const trueVariable = '' +const trueVariable = true // 2. Set this variable to be the opposite of the trueVariable (ie. false); -const falseVariable = '' +const falseVariable = false // 3. Set this variable to be undefined -const undefinedVariable = '' +const undefinedVariable = undefined // 4. get the typeof each of the above variables // hint you can use typeof variable to return a string of the variable type -const typeOfTrueVariable = '' -const typeOfFalseVariable = '' -const typeOfUndefinedVariable = '' +const typeOfTrueVariable = typeof trueVariable +const typeOfFalseVariable = typeof falseVariable +const typeOfUndefinedVariable = typeof undefinedVariable // do not edit the exported object. module.exports = { diff --git a/src/numbers.js b/src/numbers.js index ee37fa1..946d450 100644 --- a/src/numbers.js +++ b/src/numbers.js @@ -12,22 +12,22 @@ const numThree = 32 // NOT myAnswer = 336 // 1. Set this variable to numOne added to numTwo -const numOnePlusNumTwo = NaN +const numOnePlusNumTwo = numOne + numTwo // 2. Set this variable to numThree multiplied by numTwo -const numThreeTimesNumTwo = NaN +const numThreeTimesNumTwo = numThree * numTwo // 3. Set this variable to numThree divided by numOne -const numThreeDividedByNumOne = NaN +const numThreeDividedByNumOne = numThree / numOne // 4. Set this variable to numThree minus numOne -const numThreeMinusNumOne = NaN +const numThreeMinusNumOne = numThree - numOne // 5. Set this variable to the sum of numOne, numTwo and numThree -const sum = NaN +const sum = numOne + numTwo + numThree // 6. Set this variable to the sum of (numOne, numTwo, numThree) divided by numOne -const numBytes = NaN +const numBytes = (numOne + numTwo + numThree) / numOne // do not edit the exported object. module.exports = { diff --git a/src/strings.js b/src/strings.js index a846086..1ecba68 100644 --- a/src/strings.js +++ b/src/strings.js @@ -13,16 +13,16 @@ const secondName = 'Smith' // NOT twoJanes = "JaneJane" // 1. Set this variable to firstName and secondName concatenated -const fullName = null +const fullName = firstName + ' ' + secondName // 2. Set this variable to the 10th character of the alphabet variable -const tenthCharacterOfAlphabet = null +const tenthCharacterOfAlphabet = alphabet.charAt(9) // 3. Set this variable by calling a method on the alphabet variable to transform it to lower case -const lowerCaseAlphabet = null +const lowerCaseAlphabet = alphabet.toLocaleLowerCase() // 4. Set this variable by using a property on the alphabet variable to get it's length -const numberOfLettersInAlphabet = null +const numberOfLettersInAlphabet = alphabet.length // do not edit the exported object. module.exports = {