-
Notifications
You must be signed in to change notification settings - Fork 10
Brussels | 25-ITP-October | Serotonine | Sprint 2 | All exercices #20
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
serotonine
wants to merge
6
commits into
HackYourFutureBelgium:main
Choose a base branch
from
serotonine:sprint2
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6757bfb
Add package-lock.json in gitignore.
1d27ce5
HYF-module-structuring-and-testing-data: Sprint-1 exercices.
a78ceb2
Sprint2: 1-key-errors.
ae6114f
Sprint2: 2-mandatory-debug.
a248d88
Sprint2: 3-mandatory-implement.
1c8687e
Sprint2: 4-mandatory-interpret.
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
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,4 +1,5 @@ | ||
| node_modules | ||
| .DS_Store | ||
| .vscode | ||
| **/.DS_Store | ||
| **/.DS_Store | ||
| package-lock.json |
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,6 +1,12 @@ | ||
| let count = 0; | ||
|
|
||
| /* Incrementing by 1 the count value. */ | ||
| count = count + 1; | ||
| /* Check if count === 1. */ | ||
| console.log(count); | ||
| /* Incrementing by 1 the count value. */ | ||
| count = count + 1; | ||
| /* Check if count === 2. */ | ||
| console.log(count); | ||
|
|
||
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing |
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
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,2 +1,5 @@ | ||
| This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
| /* This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? */ | ||
| /* | ||
| * Just comment it. | ||
| */ |
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,4 +1,7 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| /* TypeError: Assignment to constant variable. */ | ||
| // const age = 33; | ||
| let age = 33; | ||
| age = age + 1; | ||
| /* Check if ok. */ | ||
| console.log(age); |
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,5 +1,7 @@ | ||
| // Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
| // what's the error ? | ||
|
|
||
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
| console.log(`I was born in ${cityOfBirth}`); | ||
| /* Cannot access 'cityOfBirth' before initialization */ | ||
| // const cityOfBirth = "Bolton"; |
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,2 +1,9 @@ | ||
| const 12HourClockTime = "20:53"; | ||
| const 24hourClockTime = "08:53"; | ||
| /* Js variables are not allowed to start with digit */ | ||
| /* SyntaxError: Invalid or unexpected token */ | ||
| // const 12HourClockTime = "20:53"; | ||
| // const 24hourClockTime = "08:53"; | ||
| const hourClockTime12 = "20:53"; | ||
| const hourClockTime24 = "08:53"; | ||
| /* Check if ok. */ | ||
| console.log("hourClockTime12 : " + hourClockTime12); | ||
| console.log("hourClockTime24 : " + hourClockTime24); |
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,4 +1,4 @@ | ||
| const movieLength = 8784; // length of movie in seconds | ||
| const movieLength = -8784; // length of movie in seconds | ||
|
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. Why minus? |
||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
@@ -12,14 +12,40 @@ console.log(result); | |
| // For the piece of code above, read the code and then answer the following questions | ||
|
|
||
| // a) How many variable declarations are there in this program? | ||
| /* | ||
| * 6 variable's declarations: | ||
| * movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result. | ||
| */ | ||
|
|
||
| // b) How many function calls are there? | ||
| /* | ||
| * Only console.log() | ||
| */ | ||
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| /* | ||
| * Modulo (%) is use to return the rest number of a division. | ||
| * 8784 % 60 = 8784 - (60 × Math.floor(8784 / 60)); | ||
| */ | ||
| console.log( "\nModule explained"); | ||
| console.log("8784 % 60 =" ,8784 - (60 * Math.floor(8784 / 60))); | ||
|
|
||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
| /* | ||
| * The rest number are the seconds. | ||
| * We substract them to the time length then timelength / 60 result | ||
| * is minutes (60 seconds in a minute). | ||
| */ | ||
|
|
||
| // e) What do you think the variable result represents? | ||
| // Can you think of a better name for this variable? | ||
| /* getClockTime() */ | ||
|
|
||
| // f) Try experimenting with different values of movieLength. | ||
| // Will this code work for all values of movieLength? Explain your answer | ||
| /* | ||
| * Yes but the result display is not optimal in case | ||
| * movieLength = 0 ormovieLength < 0 or totalHours === 0 or some of the value < 10. | ||
| */ | ||
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 |
|---|---|---|
|
|
@@ -14,3 +14,7 @@ Answer the following questions: | |
|
|
||
| What does `console` store? | ||
| What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
| - console.log(["message"], value.toString()) | ||
| - console.assert(assertion, "message", [optionalParams]); | ||
| - - assertion returns a boolean (false / true). If false the message will be displayed in the console. | ||
| - - E.g. console.assert(5 < 2, "You are really dumb into mathematics"); | ||
|
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. :D |
||
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,13 +1,16 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // Guess init a variable with the same name than the argument is not a good idea. | ||
|
|
||
| // call the function capitalise with a string input | ||
| // interpret the error message and figure out why an error is occurring | ||
|
|
||
| function capitalise(str) { | ||
| /* function capitalise(str) { | ||
| let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| return str; | ||
| } | ||
| } */ | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
| // SyntaxError: Identifier 'str' has already been declared | ||
| function capitalise(str) { | ||
| return `${str[0].toUpperCase()}${str.slice(1)}`; | ||
| } | ||
| console.log(capitalise("hello world")); |
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,20 +1,27 @@ | ||
| // Predict and explain first... | ||
|
|
||
| // Why will an error occur when this program runs? | ||
| // =============> write your prediction here | ||
| // Variable 'decimalNumber' is already declared. And this declaration is no needed. | ||
| // console.log(decimalNumber); will throw an error. const is block scoped. | ||
|
|
||
| // Try playing computer with the example to work out what is going on | ||
|
|
||
| function convertToPercentage(decimalNumber) { | ||
| /* function convertToPercentage(decimalNumber) { | ||
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
| return percentage; | ||
| } | ||
| console.log(decimalNumber); | ||
| console.log(decimalNumber); */ | ||
|
|
||
| // =============> write your explanation here | ||
| // SyntaxError: Identifier 'decimalNumber' has already been declared | ||
|
|
||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| function convertToPercentage(decimalNumber) { | ||
| const percentage = `${decimalNumber * 100}%`; | ||
| return percentage; | ||
| } | ||
|
|
||
| console.log(convertToPercentage(0.5)); | ||
|
|
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.
Correcting the questions makes the reader confused