-
-
Notifications
You must be signed in to change notification settings - Fork 546
Manchester | 26-ITP-Sep | Mathew Shaibu | Sprint 3 | Coursework-Sprint 3 #1586
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
Closed
MattCarolus10
wants to merge
75
commits into
CodeYourFuture:main
from
MattCarolus10:coursework/sprint-3
Closed
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
919f2bc
Hello_World JavaScript file created
MattCarolus10 f93c281
restore password.js to prep
MattCarolus10 9f085a5
1-count.js completed
MattCarolus10 0194cb3
initials.js task completed
MattCarolus10 6c5a8c8
file path task completed
MattCarolus10 b1dcb1c
4-random task completed
MattCarolus10 aed6985
0.js error fixed
MattCarolus10 dd027fa
add ; to lines
MattCarolus10 3e2a1d2
add ; to lines
MattCarolus10 b1660fd
add ; to lines
MattCarolus10 ed261ff
task 1.js completed
MattCarolus10 5031f8f
task 2.js completed
MattCarolus10 ddc8ba6
3.js task completed
MattCarolus10 8c577d5
task 4.js completed
MattCarolus10 e44ee66
percentage-change.js task completed
MattCarolus10 48b94e2
completed task 2-time-format
MattCarolus10 509ff84
explained task 0.js
MattCarolus10 f80c15b
task 1.js explained
MattCarolus10 7d0d970
task 2.js explained
MattCarolus10 5b4ed9d
task 3.js explained and completed
MattCarolus10 c41aa67
task 4.js completed and explained
MattCarolus10 08af9b8
completed and printed task 1-count.js
MattCarolus10 536761c
task 1-percentage-change explained
MattCarolus10 276f457
task 2-time-format.js explained and completed
MattCarolus10 4aa0e25
3-to-pounds
MattCarolus10 4cc01f5
interpreted task 3-to-pounds.js
MattCarolus10 0a50eb5
fix: correct console log messages for base and dir parts in 3-paths.js
MattCarolus10 ae41a8e
fix: update console log for ext part in 3-paths.js
MattCarolus10 a896a16
task 1-kkey-exercise completed
MattCarolus10 b5bda05
print file purposes
MattCarolus10 aedbcb2
created variables for personal information
MattCarolus10 655c50e
use function and parameters
MattCarolus10 276400a
practice slice function
MattCarolus10 c778acb
practice number functions
MattCarolus10 69717b1
practice substring function
MattCarolus10 9edf1ff
more substring practice
MattCarolus10 dba1c5e
padstart function
MattCarolus10 d8c4077
padEnd practice
MattCarolus10 90cadba
Math.floor & Math.random practice
MattCarolus10 903b731
lastIndexOf() function exercise
MattCarolus10 3be5165
completed
MattCarolus10 aade124
Math.round task
MattCarolus10 239699e
Math.round function task
MattCarolus10 3b45f5d
password checker task
MattCarolus10 91b22a2
password checker variable scope
MattCarolus10 5b60bb1
test wrong password
MattCarolus10 d10542b
return exercise completed
MattCarolus10 4793a56
output and return exercise completed
MattCarolus10 51e9adc
parameters arguement function
MattCarolus10 bc34e0e
1-key-error task completed
MattCarolus10 79db8a6
task 1.js completed
MattCarolus10 fb93c79
task 2.js completed
MattCarolus10 fb14e2c
clear spaces
MattCarolus10 5839e8d
task mandatory-debug completed
MattCarolus10 6b32611
task 1.js mandatory error completed
MattCarolus10 e6d47e5
task 2.js mandatory debug completed
MattCarolus10 4eb2cc6
BMI task completed
MattCarolus10 712ef52
Add explanation for getLastDigit function issue and correction
MattCarolus10 25fdf9b
cases task completed
MattCarolus10 24751a8
cases task completed
MattCarolus10 4929bf8
task 3-to-pounds completed
MattCarolus10 1b7b0d7
task 4 time format completed
MattCarolus10 e09db2b
testing for bugs
MattCarolus10 004cb3b
Minutes solved
MattCarolus10 9224cf2
bug fixed
MattCarolus10 263727a
format-time.js task completed
MattCarolus10 ae004f1
task completed
MattCarolus10 877edfa
Remove prep, password checker and function parameters
MattCarolus10 af33811
Fix multiplication parameters in console.log output
MattCarolus10 336821f
Fix variable declaration in upperCase function
MattCarolus10 e4821c0
Fix variable declaration in calculateBMI function
MattCarolus10 4556717
Fix console.log output in toPounds function
MattCarolus10 534fc0c
Fix syntax errors and improve function implementations in various files
MattCarolus10 9fdc5ce
Fix comments to clarify function behavior in multiply function
MattCarolus10 bcf8265
Refactor getLastDigit function to accept a parameter and add new pass…
MattCarolus10 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,6 +1,6 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| 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 | ||
| // Line 3 has been able to reassign the value of the count variable from 0 to 1. The operator = assign the new value to be stored as 1. |
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,10 +1,7 @@ | ||
| const firstName = "Creola"; | ||
| const middleName = "Katherine"; | ||
| const lastName = "Johnson"; | ||
| const initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; | ||
|
|
||
| // Declare a variable called initials that stores the first character of each string. | ||
| // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
| console.log(initials); | ||
|
|
||
| const initials = ``; | ||
|
|
||
| // https://www.google.com/search?q=get+first+character+of+string+mdn |
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? | ||
|
|
||
|
|
||
| // This error is a syntaxError because javaScript could not understand the text. The error can be solved by commenting the lines using ("//") |
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,8 @@ | ||
| // trying to create an age variable and then reassign the value by 1 | ||
|
|
||
| const age = 33; | ||
| let age = 33; | ||
| age = age + 1; | ||
| console.log(age); | ||
|
|
||
| // This code returns a "TypeError: Assignment to constant variable.", because the variable age has been made constant and can't be manipulated. | ||
| // To solve the problem, we have to reassign the age variable from "const" to "let", that way it will allow for further manipulation and solve the error. |
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,9 @@ | ||
| // 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}`); | ||
|
|
||
|
|
||
| // In this task, the variable was not assigned before attempting to print. Therefore, it gives the error "ReferenceError: Cannot access 'cityOfBirth' before initialization" | ||
| // The solution would be to assign the variable "cityOfBirth" first before printing the code. |
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,9 +1,8 @@ | ||
| const cardNumber = 4533787178994213; | ||
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.slice(-4); | ||
| console.log(last4Digits) | ||
|
|
||
| // The last4Digits variable should store the last 4 digits of cardNumber | ||
| // However, the code isn't working | ||
| // Before running the code, make and explain a prediction about why the code won't work | ||
| // Then run the code and see what error it gives. | ||
| // Consider: Why does it give this error? Is this what I predicted? If not, what's different? | ||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
| // The variable cardNumber is not a string and the slice() function works with strings or array | ||
|
|
||
| // Consider: Why does it give this error? | ||
| // It gave that error "TypeError: cardNumber.slice is not a function" brcause the slice() function tool are not applicable to numbers. |
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,6 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
| const HourClockTime1 = "8:53pm"; | ||
| const hourClockTime2 = "20:53"; | ||
| console.log(`${HourClockTime1}, ${hourClockTime2}`) | ||
|
|
||
| // The code displayed the error "SyntaxError: Invalid or unexpected token", this is because javaScript does not understand the variable name format. | ||
| // This error is solved by renaming the variable name starting it with an alphabet and avoiding starting the variable with a number. |
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
Empty file.
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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| console.log("One fact i love about git is that it allows people to collaborate on projects"); | ||
|
|
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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| console.log("In this exercise I will be learning different functions, and preactising them. "); | ||
|
|
||
| let userName = "Matthew"; | ||
| let location = "Manchester"; | ||
| let favoriteFood = "Jollof rice"; | ||
|
|
||
| function myInfo(userName, location, favoriteFood) { | ||
| console.log(`My name is ${userName}` ) | ||
| console.log(`I live in ${location}` ) | ||
| console.log(`My favorite food is ${favoriteFood}` ) | ||
| }; | ||
| myInfo(userName, location, favoriteFood); | ||
|
|
||
| sliceUserName = userName.slice(0, 4); | ||
| console.log(`My friends love to call me ${sliceUserName}`); | ||
|
|
||
| sliceLocation = location.lastIndexOf("h"); | ||
| console.log(sliceLocation); | ||
|
|
||
| const number1 = "50"; | ||
| const number2 = "100"; | ||
| const result = Number(number1) + Number(number2); | ||
| console.log(result); | ||
|
|
||
| let hobby = "I love football and traveling"; | ||
| let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking"); | ||
| console.log(moreHobby); | ||
|
|
||
| const passion = hobby.substring(6, 15); | ||
| console.log(passion); | ||
|
|
||
| const luckyNumber = "7"; | ||
| const changeNumber = luckyNumber.padStart(5, "0"); | ||
| console.log(changeNumber); | ||
|
|
||
| const anotherNumber = luckyNumber.padEnd(5, "0"); | ||
| console.log(anotherNumber); | ||
|
|
||
| const carPrice = 30000.50; | ||
| const updatedCarPrice = Math.floor(carPrice); | ||
| console.log(updatedCarPrice); | ||
|
|
||
| const addNumber = 20; | ||
| const addNumber2 = 30; | ||
| const addNumber3 = addNumber + addNumber2; | ||
| const addNumberResult = Math.random() * addNumber3 | ||
| console.log(addNumberResult); | ||
|
|
||
| const repeatedText = "one, two, three"; | ||
| const lastOnePosition = repeatedText.lastIndexOf("one"); | ||
| console.log(lastOnePosition); | ||
|
|
||
| // const yourName = prompt("Please enter your name: "); | ||
| // const yourLocation = prompt("Please enter your location: "); | ||
| // const yourHobby = prompt("Enter your hobby: "); | ||
| // const yourFavoriteFood = prompt("Please enter your favorite food: ") | ||
|
|
||
| // function userInfo(yourName, yourLocation, yourHobby, yourFavoriteFood) { | ||
| // console.log(`Your name is ${yourName}`) | ||
| // console.log(`You live in ${yourLocation}`) | ||
| // console.log(`Your hobby is ${yourHobby}`) | ||
| // console.log(`Your favorite food is ${yourFavoriteFood}`) | ||
| // } | ||
|
|
||
| // userInfo(yourName, yourLocation, yourHobby, yourFavoriteFood) | ||
| // Chrome devOps prompt function, variable and parameters |
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| const greeting = "Hello There !"; | ||
| console.log(greeting); | ||
|
|
||
| const name = "Matt"; | ||
| console.log(`${greeting}, I am ${name}`); | ||
|
|
||
| let location = "Manchester"; | ||
| console.log(`${greeting}, my name is ${name} and i live in ${location} `); | ||
|
|
||
| let location2 = "London"; | ||
| console.log(`${greeting}, I am ${name}, I will be traveling to ${location2} soon`); | ||
|
|
||
| console.log("Dog" === "Mango"); | ||
|
|
||
| console.log(5 + 15 === 20); | ||
|
|
||
| console.log("dog" == "dog"); | ||
|
|
||
| console.log(40+5 == "45"); | ||
|
|
||
| console.log(60+40 > 50); | ||
|
|
||
| console.log(100<= 90); | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| const password = "Matt123"; | ||
| const userInput = "Anything"; | ||
| const administrator = "Anything"; | ||
| let response = " "; | ||
|
|
||
| if (password === userInput) { | ||
| response = "Login successful"; | ||
| } else if (userInput === administrator) { | ||
| response = "Welcome to the site"; | ||
| } | ||
| else { | ||
| response = "Please try again"; | ||
| } | ||
| console.log(response); | ||
|
|
||
|
|
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,23 @@ | ||
| // Predict and explain first... | ||
| // =============> write your prediction here | ||
| // ======> write your prediction here: I predict that the code should cut out, and make the first letter of the string an uppercase letter, | ||
| // then add every letters that comes after | ||
|
|
||
| // 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; | ||
| } | ||
| // function capitalise(str) { | ||
| // let str= `${str[0].toUpperCase()}${str.slice(1)}` | ||
| // return str; | ||
| // } | ||
|
|
||
|
|
||
| // =============> write your explanation here: The error read "SyntaxError: Identifier 'str' has already been declared", | ||
| // this is as a result of having two variables with same name. The error occoured in this code because the variable "str" has been decleared twice | ||
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
|
|
||
| function capitalise(str) { | ||
| let str2= `${str[0].toUpperCase()}${str.slice(1)}` | ||
| return str2; | ||
| } | ||
| console.log(capitalise("money")) |
Oops, something went wrong.
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.
Hello! Fantastic job analyzing the error message. You correctly spotted that using let str = ... was trying to re-declare the parameter, causing that SyntaxError. Great problem-solving!
Your solution using str2 works and successfully capitalizes the word. I just have a couple of questions to help us think about code cleanliness:
You are doing amazing. Let me know what you think! 😊