generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 196
LONDON | May-2025 | Aida Eslamimoghadam| Module-Structuring-and-Testing-Data | Sprint-2 #516
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
aydaeslami
wants to merge
11
commits into
CodeYourFuture:main
Choose a base branch
from
aydaeslami: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
11 commits
Select commit
Hold shift + click to select a range
2b3cebc
Key-Exercises
aydaeslami b0c4234
Mandatory-errors
aydaeslami 4c52251
Mandatory-interpret
aydaeslami d518c0c
Stretch & Key exercise num 3
aydaeslami 73cd2e5
Sprint2 /Key Error
aydaeslami c7bbe5d
Mandatory-debug
aydaeslami af0409e
Mandatory-implement
aydaeslami d13a01a
Mandatory-Interpret
aydaeslami 54b19d6
Stretch-extend
aydaeslami 5c0ad59
trial
aydaeslami 28dff55
sprint 1 removed
aydaeslami 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,13 +1,24 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// =============> ANSWER | ||
// It takes a string and change its first letter to capitial letter aida -----> Aida | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
|
||
// function capitalise(str) { | ||
// let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
// return str; | ||
// } | ||
|
||
// // =============> ANSWER | ||
// SyntaxError: Identifier 'str' has already been declared | ||
// It is not allow to redeclare the parameter str inside the function | ||
|
||
// // =============> write your new code here | ||
let name = "aida"; | ||
|
||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
return `${str[0].toUpperCase()}${str.slice(1)}`; | ||
} | ||
|
||
// =============> write your explanation here | ||
// =============> write your new code here | ||
console.log(capitalise("aida")); |
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,36 @@ | ||
// Predict and explain first... | ||
// =============> ANSWER | ||
// convertToPercentage function takes a number and multiplaited it to 100,to give the percentage and then return it. | ||
// but it doesn't work because we did'nt call it in the main part. | ||
// Also we can not declare a variable which has been declared already | ||
|
||
// Why will an error occur when this program runs? | ||
// =============> write your prediction here | ||
// we can not declare a variable which has been declared already | ||
// SyntaxError: Identifier 'decimalNumber' has already been declared | ||
|
||
// Try playing computer with the example to work out what is going on | ||
|
||
function convertToPercentage(decimalNumber) { | ||
const decimalNumber = 0.5; | ||
const percentage = `${decimalNumber * 100}%`; | ||
// function convertToPercentage(decimalNumber) { | ||
// const decimalNumber = 0.5; | ||
// const percentage = `${decimalNumber * 100}%`; | ||
|
||
return percentage; | ||
} | ||
// return percentage; | ||
// } | ||
|
||
console.log(decimalNumber); | ||
// console.log(decimalNumber); | ||
|
||
// =============> write your explanation here | ||
// =============> ANSWER | ||
// It doesn't work because we did'nt call the function. | ||
|
||
// Finally, correct the code to fix the problem | ||
|
||
// =============> write your new code here | ||
|
||
const decimalNumber = 0.5; | ||
function convertToPercentage(decimalNumber) { | ||
const percentage = `${decimalNumber * 100}%`; | ||
|
||
return percentage; | ||
} | ||
|
||
console.log(convertToPercentage(decimalNumber)); |
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 BEFORE you run any code... | ||
// This function does'nt work because we can not set literal value as a parameter. | ||
|
||
// this function should square any number but instead we're going to get an error | ||
|
||
// =============> write your prediction of the error here | ||
// An error for number instead of parameter | ||
|
||
function square(3) { | ||
return num * num; | ||
} | ||
// function square(3) { | ||
// return num * num; | ||
// } | ||
|
||
// =============> write the error message here | ||
|
||
// SyntaxError: Unexpected number | ||
|
||
// =============> explain this error message here | ||
// JavaScript is expecting a variable name (parameter) not a literal value | ||
|
||
// Finally, correct the code to fix the problem | ||
|
||
// =============> write your new code here | ||
|
||
function square(num) { | ||
return num * num; | ||
} | ||
|
||
console.log(square(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
// Predict and explain first... | ||
// function should multiply a by b and print the answer. and it DOESN'T return . | ||
// So in the Console.log we don't have the result. | ||
|
||
// =============> write your prediction here | ||
|
||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
// function multiply(a, b) { | ||
// console.log(a * b); | ||
// } | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// we don't have result for function because there is no return in function . "The result of multiplying 10 and 32 is undefined" | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
|
||
function multiply(a, b) { | ||
return a * b; | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
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,22 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// The code doesn't work because the expression a + b comes after the return statement | ||
// Once the compiler reaches return it exit the function. | ||
// There is no error. we just don't have answer | ||
// function sum(a, b) { | ||
// return; | ||
// a + b; | ||
// } | ||
|
||
function sum(a, b) { | ||
return; | ||
a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// There is no error. we just do not have correct answer.===> The sum of 10 and 32 is undefined | ||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
|
||
function sum(a, b) { | ||
return a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
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,43 @@ | ||
// Predict and explain first... | ||
|
||
// Predict the output of the following code: | ||
// =============> Write your prediction here | ||
// This code should return the last digit of each number but again it doesn't return a correct number because it ask to slice(-1) of "num" | ||
// Predict the output of the following code: | ||
// 3 | ||
// 3 | ||
// 3 | ||
|
||
const num = 103; | ||
// const num = 103; | ||
|
||
function getLastDigit() { | ||
return num.toString().slice(-1); | ||
} | ||
// function getLastDigit() { | ||
// return num.toString().slice(-1); | ||
// } | ||
|
||
console.log(`The last digit of 42 is ${getLastDigit(42)}`); | ||
console.log(`The last digit of 105 is ${getLastDigit(105)}`); | ||
console.log(`The last digit of 806 is ${getLastDigit(806)}`); | ||
// console.log(`The last digit of 42 is ${getLastDigit(42)}`); | ||
// console.log(`The last digit of 105 is ${getLastDigit(105)}`); | ||
// console.log(`The last digit of 806 is ${getLastDigit(806)}`); | ||
|
||
// Now run the code and compare the output to your prediction | ||
// =============> write the output here | ||
// 3 3 3 | ||
// Explain why the output is the way it is | ||
// | ||
|
||
// =============> write your explanation here | ||
// because we didn't send our parameter to function. | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
|
||
const num = 103; | ||
|
||
function getLastDigit(num) { | ||
return num.toString().slice(-1); | ||
} | ||
|
||
console.log(`The last digit of 42 is ${getLastDigit(42)}`); | ||
console.log(`The last digit of 105 is ${getLastDigit(105)}`); | ||
console.log(`The last digit of 806 is ${getLastDigit(806)}`); | ||
|
||
// This program should tell the user the last digit of each number. | ||
// Explain why getLastDigit is not working properly - correct the problem |
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
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
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.
Why not declare the variable and start its name with a lowercase letter?
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.
Hi Cj,
Thank you for your review.
I am trying to fix this issu. I learnt CamelCase incorrectly and I know it use for build-in function.
sorry about it.
I also fixed Branch issu.
Many thanks
Aida