-
Notifications
You must be signed in to change notification settings - Fork 61
Tibor #34
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
Open
Tibor22
wants to merge
12
commits into
boolean-uk:main
Choose a base branch
from
Tibor22:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tibor #34
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9ad5f5b
EX:Variables
Tibor22 d857b58
for-loop-basic
Tibor22 9051410
loops with arrays
Tibor22 4aec01c
creating-function-solved
Tibor22 6d80266
call-functions
Tibor22 041bd60
multiple-argument-functions
Tibor22 2e592b7
string
Tibor22 04a6b8a
numbers done
Tibor22 be5d07e
objects done
Tibor22 59e51e8
arrays done
Tibor22 658f2bb
done conditionals
Tibor22 10c3244
done strings
Tibor22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| const { a, b } = require('../../src/variables/assignment.js') | ||
| const { a, b } = require("../../src/variables/assignment.js"); | ||
|
|
||
| describe("Variable Assignment:", () => { | ||
| it("firstNumber is 20", () => { | ||
| expect(a).toEqual(20) | ||
| }) | ||
| expect(a).toEqual(20); | ||
| }); | ||
|
|
||
| it("secondNumber is 42", () => { | ||
| expect(b).toEqual(42) | ||
| }) | ||
| }) | ||
| expect(b).toEqual(42); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,16 @@ | ||
| // This function should accept a boolean value and return the string | ||
| // "Well done, you passed!" if the value is true, or "Sorry, try again" | ||
| // if the value is false. | ||
| function getResult (didPass) { | ||
|
|
||
| function getResult(didPass) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (didPass) { | ||
| return "Well done, you passed!"; | ||
| } else { | ||
| return "Sorry, try again"; | ||
| } | ||
| } | ||
|
|
||
| module.exports = { | ||
| a: getResult | ||
| } | ||
| a: getResult, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,33 @@ | ||
| // TODO: Implement the functions below to make the tests pass | ||
|
|
||
| // This function should return true if there are no elements in the array, false otherwise | ||
| function isArrayEmpty (array) { | ||
|
|
||
| function isArrayEmpty(array) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (array.length === 0) return true; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| // This function should return true if num1 is greater than num2, false otherwise | ||
| function isGreaterThan (num1, num2) { | ||
|
|
||
| function isGreaterThan(num1, num2) { | ||
| // TODO: write code in this function body to pass the tests | ||
| if (num1 > num2) return true; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| // This function should return the lowest number in the passed array | ||
| function findLowest (nums) { | ||
|
|
||
| function findLowest(nums) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| let lowest = Math.min(...nums); | ||
|
|
||
| return lowest; | ||
| } | ||
|
|
||
| module.exports = { | ||
| a: isArrayEmpty, | ||
| b: isGreaterThan, | ||
| c: findLowest | ||
| } | ||
| c: findLowest, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,56 @@ | ||
| // This function should return true if the passed string is equal to "Hello" | ||
| function isHello (val1) { | ||
| function isHello(val1) { | ||
| if (val1 === "Hello") return true; | ||
| return false; | ||
|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| } | ||
|
|
||
| // This function should return true if the passed string is not equal to "Hello" | ||
| function isNotHello (val1) { | ||
|
|
||
| function isNotHello(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1 !== "Hello") return true; | ||
| return false; | ||
| } | ||
|
|
||
| // This function should return true if the string val1 is is longer | ||
| // than string val2 | ||
| function isLongerThan (val1, val2) { | ||
|
|
||
| function isLongerThan(val1, val2) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1.length > val2.length) return true; | ||
| return false; | ||
| } | ||
|
|
||
| // This function should return true if the string passed in the function's first | ||
| // argument has an odd number of vowels | ||
|
|
||
| function hasOddNumberVowels (val1) { | ||
|
|
||
| function hasOddNumberVowels(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
| let vowel_list = "aeiouAEIOU"; | ||
| let vcount = 0; | ||
|
|
||
| for (let x = 0; x < val1.length; x++) { | ||
| if (vowel_list.indexOf(val1[x]) !== -1) { | ||
| vcount += 1; | ||
| } | ||
| } | ||
|
|
||
| if (vcount % 2 !== 0) return true; | ||
| return false; | ||
| } | ||
|
|
||
| // this function should return the middle character of a string if it has an odd number | ||
| // of characters. If there are an even number of characters the function should return | ||
| // the middle two letters | ||
|
|
||
| function getMiddleLetter (val1) { | ||
| function getMiddleLetter(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1.length % 2 === 0) { | ||
| return val1[val1.length / 2 - 1] + val1[val1.length / 2]; | ||
| } else { | ||
| return val1[Math.floor(val1.length / 2)]; | ||
| } | ||
| } | ||
|
|
||
| // This function should return the name of the season for the provided | ||
|
|
@@ -47,9 +62,49 @@ function getMiddleLetter (val1) { | |
| // Summer - June to August | ||
| // Autumn - September to November | ||
| // Winter - December to February | ||
| function seasonForMonth (monthName) { | ||
|
|
||
| function seasonForMonth(monthName) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| switch (monthName) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. case "January": Have a look at switch() statement syntax in MDN |
||
| case (monthName = "January"): | ||
| return "Winter"; | ||
| break; | ||
| case (monthName = "February"): | ||
| return "Winter"; | ||
| break; | ||
| case (monthName = "December"): | ||
| return "Winter"; | ||
| break; | ||
| case (monthName = "March"): | ||
| return "Spring"; | ||
| break; | ||
| case (monthName = "April"): | ||
| return "Spring"; | ||
| break; | ||
| case (monthName = "May"): | ||
| return "Spring"; | ||
| break; | ||
| case (monthName = "June"): | ||
| return "Summer"; | ||
| break; | ||
| case (monthName = "July"): | ||
| return "Summer"; | ||
| break; | ||
| case (monthName = "August"): | ||
| return "Summer"; | ||
| break; | ||
| case (monthName = "September"): | ||
| return "Autumn"; | ||
| break; | ||
| case (monthName = "October"): | ||
| return "Autumn"; | ||
| break; | ||
| case (monthName = "November"): | ||
| return "Autumn"; | ||
| break; | ||
| default: | ||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| module.exports = { | ||
|
|
@@ -58,5 +113,5 @@ module.exports = { | |
| c: isLongerThan, | ||
| d: hasOddNumberVowels, | ||
| e: getMiddleLetter, | ||
| f: seasonForMonth | ||
| } | ||
| f: seasonForMonth, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| // do not edit this section | ||
| const cities = ['London', 'Shanghai', 'New York', 'Delhi', 'Kuala Lumpur'] | ||
| const cities = ["London", "Shanghai", "New York", "Delhi", "Kuala Lumpur"]; | ||
|
|
||
| // TODO: write code to pass the tests | ||
|
|
||
| // Set names equal to an array containing 'Bob', 'Jane', 'Joanna' in that order | ||
| const names = null | ||
| const names = ["Bob", "Jane", "Joanna"]; | ||
|
|
||
| // Set fourthCity to the 4th element in the cities array | ||
| const fourthCity = '' | ||
| const fourthCity = cities[3]; | ||
|
|
||
| // Set firstCity to the 1st element in the cities array | ||
| const firstCity = '' | ||
| const firstCity = cities[0]; | ||
|
|
||
| // Set lengthOfCitiesArray to the length of the cities array | ||
| const lengthOfCitiesArray = NaN | ||
| const lengthOfCitiesArray = cities.length; | ||
|
|
||
| // Do not edit this exported object | ||
| module.exports = { | ||
| a: names, | ||
| b: fourthCity, | ||
| c: firstCity, | ||
| d: lengthOfCitiesArray | ||
| } | ||
| d: lengthOfCitiesArray, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ( num >= lower && num <= upper )