diff --git a/caesar/caesar.js b/caesar/caesar.js index 42bc82b..f4d6a25 100644 --- a/caesar/caesar.js +++ b/caesar/caesar.js @@ -1,4 +1,4 @@ -var caesar = function() { +const caesar = function() { } diff --git a/caesar/caesar.spec.js b/caesar/caesar.spec.js index 8f3468c..49fe254 100644 --- a/caesar/caesar.spec.js +++ b/caesar/caesar.spec.js @@ -1,4 +1,4 @@ -var caesar = require('./caesar') +const caesar = require('./caesar') describe('caesar', function() { it('works with single letters', function() { @@ -19,4 +19,7 @@ describe('caesar', function() { xit('works with large shift factors', function() { expect(caesar('Hello, World!', 75)).toEqual('Ebiil, Tloia!'); }); + xit('works with large negative shift factors', function() { + expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!'); + }); }); diff --git a/calculator/calculator.spec.js b/calculator/calculator.spec.js index 7a8bc3c..150a0aa 100644 --- a/calculator/calculator.spec.js +++ b/calculator/calculator.spec.js @@ -1,4 +1,4 @@ -var calculator = require ('./calculator.js'); +const calculator = require ('./calculator.js'); describe('add', function() { it('adds 0 and 0', function() { diff --git a/fibonacci/fibonacci.js b/fibonacci/fibonacci.js index 65b28bb..fd597f9 100644 --- a/fibonacci/fibonacci.js +++ b/fibonacci/fibonacci.js @@ -1,4 +1,4 @@ -var fibonacci = function() { +const fibonacci = function() { } diff --git a/fibonacci/fibonacci.spec.js b/fibonacci/fibonacci.spec.js index 956e418..d7adebe 100644 --- a/fibonacci/fibonacci.spec.js +++ b/fibonacci/fibonacci.spec.js @@ -1,4 +1,4 @@ -var fibonacci = require('./fibonacci') +const fibonacci = require('./fibonacci') describe('fibonacci', function() { it('works', function() { diff --git a/generator-exercise/generators/app/templates/title.js b/generator-exercise/generators/app/templates/title.js index baedf2c..34030c5 100644 --- a/generator-exercise/generators/app/templates/title.js +++ b/generator-exercise/generators/app/templates/title.js @@ -1,4 +1,4 @@ -var <%= title %> = function() { +let <%= title %> = function() { } diff --git a/generator-exercise/generators/app/templates/title.spec.js b/generator-exercise/generators/app/templates/title.spec.js index 7db94cc..fa4ce97 100644 --- a/generator-exercise/generators/app/templates/title.spec.js +++ b/generator-exercise/generators/app/templates/title.spec.js @@ -1,4 +1,4 @@ -var <%= title %> = require('./<%=title%>') +let <%= title %> = require('./<%=title%>') describe('<%=title%>', function() { it('EDITME', function() { diff --git a/helloWorld/README.md b/helloWorld/README.md index 2a51d18..cb5114c 100644 --- a/helloWorld/README.md +++ b/helloWorld/README.md @@ -10,7 +10,7 @@ This setup should be the same for all of the exercises. The plain javascript fi Let's look at the spec file first: ```javascript -var helloWorld = require('./helloWorld'); +const helloWorld = require('./helloWorld'); describe('Hello World', function() { it('says hello world', function() { @@ -26,7 +26,7 @@ For now you do not need to worry about how to write tests, but you should try to so let's look at the javascript file: ```javascript -var helloWorld = function() { +const helloWorld = function() { return '' } @@ -40,7 +40,7 @@ Just to make sure, in case you're confused at this point, the test is telling yo this is what the final function should look like: ```javascript -var helloWorld = function() { +const helloWorld = function() { return 'Hello, World!' } diff --git a/helloWorld/helloWorld.js b/helloWorld/helloWorld.js index cf8cd75..a41264d 100644 --- a/helloWorld/helloWorld.js +++ b/helloWorld/helloWorld.js @@ -1,5 +1,5 @@ -var helloWorld = function() { +const helloWorld = function() { return '' } -module.exports = helloWorld \ No newline at end of file +module.exports = helloWorld diff --git a/helloWorld/helloWorld.spec.js b/helloWorld/helloWorld.spec.js index bb79262..c98e534 100644 --- a/helloWorld/helloWorld.spec.js +++ b/helloWorld/helloWorld.spec.js @@ -1,7 +1,7 @@ -var helloWorld = require('./helloWorld'); +const helloWorld = require('./helloWorld'); describe('Hello World', function() { it('says hello world', function() { expect(helloWorld()).toEqual('Hello, World!'); }); -}); \ No newline at end of file +}); diff --git a/leapYears/README.md b/leapYears/README.md index 30bf967..476febf 100644 --- a/leapYears/README.md +++ b/leapYears/README.md @@ -10,5 +10,5 @@ leapYears(1985) // is not a leap year: returns false ``` -## hints +## Hints - use an `if` statement and `&&` to make sure all the conditions are met properly diff --git a/leapYears/leapYears.js b/leapYears/leapYears.js index 7884b78..ac786a2 100644 --- a/leapYears/leapYears.js +++ b/leapYears/leapYears.js @@ -1,4 +1,4 @@ -var leapYears = function() { +const leapYears = function() { } diff --git a/leapYears/leapYears.spec.js b/leapYears/leapYears.spec.js index b58dadb..0d4d7d4 100644 --- a/leapYears/leapYears.spec.js +++ b/leapYears/leapYears.spec.js @@ -1,4 +1,4 @@ -var leapYears = require('./leapYears') +const leapYears = require('./leapYears') describe('leapYears', function() { it('works with non century years', function() { diff --git a/palindromes/palindromes.js b/palindromes/palindromes.js index a27496d..ccfda4b 100644 --- a/palindromes/palindromes.js +++ b/palindromes/palindromes.js @@ -1,4 +1,4 @@ -var palindromes = function() { +const palindromes = function() { } diff --git a/palindromes/palindromes.spec.js b/palindromes/palindromes.spec.js index e5e594d..1b24286 100644 --- a/palindromes/palindromes.spec.js +++ b/palindromes/palindromes.spec.js @@ -1,4 +1,4 @@ -var palindromes = require('./palindromes') +const palindromes = require('./palindromes') describe('palindromes', function() { it('works with single words', function() { diff --git a/pig_latin/pigLatin.spec.js b/pig_latin/pigLatin.spec.js index 1eb4bfb..bbc8463 100644 --- a/pig_latin/pigLatin.spec.js +++ b/pig_latin/pigLatin.spec.js @@ -15,7 +15,7 @@ // See https://en.wikipedia.org/wiki/Pig_Latin for more details. -var pigLatin = require("./pigLatin.js"); +const pigLatin = require("./pigLatin.js"); describe('#translate', function() { it('translates a word beginning with a vowel', function() { @@ -61,4 +61,4 @@ describe('#translate', function() { s = pigLatin.translate("the quick brown fox"); expect(s).toEqual("ethay ickquay ownbray oxfay"); }); -}); \ No newline at end of file +}); diff --git a/removeFromArray/README.md b/removeFromArray/README.md index 9b3ebc0..44ee922 100644 --- a/removeFromArray/README.md +++ b/removeFromArray/README.md @@ -8,7 +8,7 @@ remove([1,2,3,4], 3) // should remove 3 and return [1,2,4] -## hints +## Hints the first test on this one is fairly easy, but there are a few things to think about(or google) here for the later tests: - how to remove a single element from an array - how to deal with multiple optional arguments in a javascript function diff --git a/removeFromArray/removeFromArray.js b/removeFromArray/removeFromArray.js index d36b8b1..11efd5c 100644 --- a/removeFromArray/removeFromArray.js +++ b/removeFromArray/removeFromArray.js @@ -1,4 +1,4 @@ -var removeFromArray = function() { +const removeFromArray = function() { } diff --git a/removeFromArray/removeFromArray.spec.js b/removeFromArray/removeFromArray.spec.js index ff94e9a..28c744c 100644 --- a/removeFromArray/removeFromArray.spec.js +++ b/removeFromArray/removeFromArray.spec.js @@ -1,4 +1,4 @@ -var removeFromArray = require('./removeFromArray') +const removeFromArray = require('./removeFromArray') describe('removeFromArray', function() { it('removes a single value', function() { diff --git a/repeatString/README.md b/repeatString/README.md index 85a0634..324744d 100644 --- a/repeatString/README.md +++ b/repeatString/README.md @@ -6,12 +6,13 @@ Write a function that simply repeats the string a given number of times: repeatString('hey', 3) // returns 'heyheyhey' ``` -You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the x in front of the it() function. +You will notice in this exercise that there are multiple tests (see in file `repeatString.spec.js`). Only the first test is currently enabled. So after making sure that this first one passes, enable the others one by one by deleting the `x` in front of the `it()` function. -## hints +## Hints -You're going to want to use a loop for this one. +- You're going to want to use a loop for this one. -Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop. +- Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop. +- If running `jasmine tempConversion/tempConversion.spec.js` raises `Temporarily disabled with xit` errors, make sure you have enabled the rest of the tests (see above). diff --git a/repeatString/repeatString.js b/repeatString/repeatString.js index 49dfa90..770119a 100644 --- a/repeatString/repeatString.js +++ b/repeatString/repeatString.js @@ -1,4 +1,4 @@ -var repeatString = function() { +const repeatString = function() { } diff --git a/repeatString/repeatString.spec.js b/repeatString/repeatString.spec.js index 3a33a3f..931b437 100644 --- a/repeatString/repeatString.spec.js +++ b/repeatString/repeatString.spec.js @@ -1,4 +1,4 @@ -var repeatString = require('./repeatString') +const repeatString = require('./repeatString') describe('repeatString', function() { it('repeats the string', function() { diff --git a/reverseString/README.md b/reverseString/README.md index dfb00de..578adc1 100644 --- a/reverseString/README.md +++ b/reverseString/README.md @@ -11,5 +11,5 @@ You will notice in this exercise that there are multiple tests, after making the -## hints +## Hints Strings in JavaScript cannot be reversed directly so you're going to have to split it into something else first.. do the reversal and then join it back together into a string. diff --git a/reverseString/reverseString.js b/reverseString/reverseString.js index bca22be..febb577 100644 --- a/reverseString/reverseString.js +++ b/reverseString/reverseString.js @@ -1,5 +1,5 @@ -var reverseString = function() { +const reverseString = function() { } -module.exports = reverseString \ No newline at end of file +module.exports = reverseString diff --git a/reverseString/reverseString.spec.js b/reverseString/reverseString.spec.js index c61ed13..e48840c 100644 --- a/reverseString/reverseString.spec.js +++ b/reverseString/reverseString.spec.js @@ -1,4 +1,4 @@ -var reverseString = require('./reverseString') +const reverseString = require('./reverseString') describe('reverseString', function() { it('reverses single word', function() { @@ -12,4 +12,4 @@ describe('reverseString', function() { xit('works with numbers and punctuation', function() { expect(reverseString('123! abc!')).toEqual('!cba !321') }) -}); \ No newline at end of file +}); diff --git a/snakeCase/snakeCase.js b/snakeCase/snakeCase.js index d14f180..c948201 100644 --- a/snakeCase/snakeCase.js +++ b/snakeCase/snakeCase.js @@ -1,4 +1,4 @@ -var snakeCase = function() { +const snakeCase = function() { } diff --git a/snakeCase/snakeCase.spec.js b/snakeCase/snakeCase.spec.js index 7664be0..cce17d2 100644 --- a/snakeCase/snakeCase.spec.js +++ b/snakeCase/snakeCase.spec.js @@ -1,4 +1,4 @@ -var snakeCase = require('./snakeCase') +const snakeCase = require('./snakeCase') describe('snakeCase', function() { it('works with simple lowercased phrases', function() { diff --git a/sumAll/README.md b/sumAll/README.md index f399eda..64072a0 100644 --- a/sumAll/README.md +++ b/sumAll/README.md @@ -7,7 +7,7 @@ sumAll(1, 4) // returns the sum of 1 + 2 + 3 + 4 which is 10 ``` -## hints +## Hints Think about how you would do this on pen and paper and then how you might translate that process into code: - create a variable to hold the final sum diff --git a/sumAll/sumAll.js b/sumAll/sumAll.js index 863a79d..4030fe8 100644 --- a/sumAll/sumAll.js +++ b/sumAll/sumAll.js @@ -1,4 +1,4 @@ -var sumAll = function() { +const sumAll = function() { } diff --git a/sumAll/sumAll.spec.js b/sumAll/sumAll.spec.js index 7f48e7a..520adc1 100644 --- a/sumAll/sumAll.spec.js +++ b/sumAll/sumAll.spec.js @@ -1,4 +1,4 @@ -var sumAll = require('./sumAll') +const sumAll = require('./sumAll') describe('sumAll', function() { it('sums numbers within the range', function() { diff --git a/tempConversion/README.md b/tempConversion/README.md index 959d029..bd3954e 100644 --- a/tempConversion/README.md +++ b/tempConversion/README.md @@ -1,14 +1,17 @@ # Exercise 06 - tempConversion -This exercise asks you to create more than one function so the module.exports section of the spec file looks a little different this time. Nothing to worry about, we're just packaging the functions into an object to be exported. - -Write two functions that convert temperatures from Fahrenheit to Celsius (and the other way around): +Write two functions that convert temperatures from Fahrenheit to Celsius, and vice versa: ``` ftoc(32) // fahrenheit to celsius, should return 0 ctof(0) // celsius to fahrenheit, should return 32 ``` +Because we are human, we want the result temperature to be rounded to one decimal place: i.e., `ftoc(100)` should return `37.8` and not `37.77777777777778`. -## hints -The math here is fairly straightforward.. just google the formula and implement it in the code +This exercise asks you to create more than one function so the `module.exports` section of the spec file looks a little different this time. Nothing to worry about, we're just packaging both functions into a single object to be exported. + +## Hints +- You can find the relevant formulae on [Wikipedia](https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature). + +- Try to find by yourself on the Internet how to round a number to 1 decimal place in JavaScript. If you struggle, have a look [here](https://stackoverflow.com/q/7342957/5433628). diff --git a/tempConversion/tempConversion.js b/tempConversion/tempConversion.js index 969c37e..4fa21ee 100644 --- a/tempConversion/tempConversion.js +++ b/tempConversion/tempConversion.js @@ -1,9 +1,9 @@ -var ftoc = function() { - +const ftoc = function() { + } -var ctof = function() { - +const ctof = function() { + } module.exports = { diff --git a/tempConversion/tempConversion.spec.js b/tempConversion/tempConversion.spec.js index 6f69a7e..0dc9168 100644 --- a/tempConversion/tempConversion.spec.js +++ b/tempConversion/tempConversion.spec.js @@ -1,4 +1,4 @@ -var {ftoc, ctof} = require('./tempConversion') +const {ftoc, ctof} = require('./tempConversion') describe('ftoc', function() { it('works', function() {