-
-
Notifications
You must be signed in to change notification settings - Fork 195
London | May-2025 | Reza Jahanimir | Sprint-1 #489
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
base: main
Are you sure you want to change the base?
Changes from all commits
4537db5
2c8408a
e07fba5
b5673e8
f946b02
e7ba13d
0def05a
6421e9f
87d44eb
259306e
be72b0d
b47e499
cf581dd
3999f62
d314a95
078e279
54f716e
f7e6a17
72c375f
1d85b48
73cc423
77b600c
637cd50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. You've identified correctly what each of the math operations is doing. Can you describe what the overall purpose of the line is? What will the output of num be? 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. Great explanation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
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? | ||
|
||
//we sole this by witting these two as comments |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// trying to create an age variable and then reassign the value by 1 | ||
|
||
const age = 33; | ||
let age = 33; | ||
age = age + 1; | ||
|
||
// we have to use let as it allows the value to be reassign |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
// 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}`); | ||
// the system reads the code top to bottom and because the variable has been create/define before | ||
// the consol.log it can not recognize the variable | ||
|
||
//Wrong | ||
//console.log(`I was born in ${cityOfBirth}`); | ||
//const cityOfBirth = "Bolton"; | ||
|
||
//correct | ||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
|
||
|
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. You are correct that 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. This works in this case. Would this still work if the number was being passed as a parameter? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
|
||
// 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 | ||
// result as a string | ||
let cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.toString().slice(-4); | ||
console.log(last4Digits); // Output: "4213" | ||
|
||
|
||
// result as a number | ||
const last4DigitsNum = Number(cardNumber.toString().slice(-4)); | ||
console.log(last4DigitsNum); // Output: 4213 | ||
|
||
|
||
// the function your asked return string | ||
function last4DigitsStr(cardNumber) { | ||
const last4Digs= cardNumber.toString().slice(-4); | ||
return last4Digs; | ||
} | ||
|
||
// the function your asked return number | ||
function last4DigitsNum(number) { | ||
const last4Digs= Number(number.toString().slice(-4)); | ||
return last4Digs; | ||
} |
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 are you talking about "Go" variable naming rules here? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const HourClockTime24 = "20:53"; | ||
const hourClockTime12 = "08:53"; | ||
|
||
// Go Variable Naming Rules | ||
// A variable can have a short name (like x and y) or a more descriptive name (age, price, carname, etc.). | ||
|
||
// Go variable naming rules: | ||
|
||
// A variable name must start with a letter or an underscore character (_) | ||
// A variable name cannot start with a digit | ||
// A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ ) | ||
// Variable names are case-sensitive (age, Age and AGE are three different variables) | ||
// There is no limit on the length of the variable name | ||
// A variable name cannot contain spaces | ||
// The variable name cannot be any Go keywords |
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. a) You have found 2 function calls correctly, can you see any others? 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. Very good answers |
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. Good answers for most of these. 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. Good suggestions |
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.
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. Good work investigating these functions |
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.
Good solution, but can you see any places here where you could clean up the code style?
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.
This looks much neater - especially having all the logs together