-
-
Notifications
You must be signed in to change notification settings - Fork 195
Sheffield | May-2025 | Hassan Osman | Sprint-1 #469
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?
Sheffield | May-2025 | Hassan Osman | Sprint-1 #469
Conversation
Sprint-1/1-key-exercises/1-count.js
Outdated
Answer: in line 3, the variable count gets reassigned a new value which is the sum of the old value and 1. | ||
In other words, the variable count is now adding 1 to its old value to obtain a new value. |
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.
Operation like count = count + 1
is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
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.
Done!
Sprint-1/1-key-exercises/4-random.js
Outdated
2. Math.floor(x) it rounds down x to a value that is less than or equal to x, while Math.random() it generates random | ||
numbers that are equal to 0 and less than 1. | ||
3. before we multiply (Math.random() by (maximum - minimum + 1) or vice versa, each expression gets evaulated | ||
first on its own. Math.random() leads to an integer between 0 and less 1, while (maximum - minimum + 1)) evaluates | ||
to 100. Then multiplication comes into place and we get floats from 0.00 and less than 100. Having Math.floor() | ||
as a method basically means we now have random integers from 0 and 99. By considering the last part of the value | ||
assigned to num, we now have random integers from 1 and 100 (both included). |
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.
-
A concise and precise way to describe a range of values is to use interval notation.
For example, we can sayMath.random() returns a random number in the interval [0, 1)
. -
Your description is correct but is a little bit verbose.
Could you try using ChatGPT to find a clearer, more concise way to describe the code?
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.
Done
Sprint-1/2-mandatory-errors/4.js
Outdated
const ClockTime24hour = "08:53"; |
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.
-
Have you also noticed the variable names do not quite match the values assigned to the variable?
-
In JS naming convention, variable names (include identifiers declared using
const
) usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g.,Math
)
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.
Changed this now.
|
||
c) line 4 & line 5 | ||
|
||
d) line 1 & line 2 |
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.
Lines 7 and 8 are also declarations, although they are not really "variables".
e) The last expression gets rid of all the commas present in the declared variables in line 1 & 2. or in other words, replaces them commas with | ||
no space between the characters separated by the commas. |
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.
Can you ask ChatGPT to describe the code at line 5, and see if you can use something it suggests in your description?
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.
Done!
|
||
/* | ||
a) There are 6 in total. | ||
b) 0 function calls. |
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.
The number of function calls is more than 0.
f) it works. However, if there's enough time to form a whole hour(s) for example the results shows the total mins and total secs and so | ||
on. So I'd say it works. |
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.
if there's enough time to form a whole hour(s) for example the results shows the total mins and total secs and so
on.
What do you mean by this statement?
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.
I was basically trying to say that it does work for all movie durations. However, and that depending on the value you may end up with 0 for the hour part and only values for the mins and secs or 0 for both hours and mins and only value for secs for even 0 for all hour, min & sec parts (if movieLength = 0 secs). Anyway, i've rephrased and simplified my response now.
Sprint-1/4-stretch-explore/chrome.md
Outdated
What is the return value of `prompt`? | ||
//undefined |
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.
Note: To view the return value of a function call, you need to output the return value to the console as console.log( function_call(...) )
.
You can also find out exactly what the function returns from the MDN Web Docs website.
|
||
Answer the following questions: | ||
|
||
What does `console` store? | ||
//console doesn't store. it displays. |
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.
The question is asking what kind of properties are stored in the console
object.
Sprint-1/4-stretch-explore/chrome.md
Outdated
@@ -19,4 +19,4 @@ Now try invoking the function `prompt` with a string input of `"What is your nam | |||
What effect does calling the `prompt` function have? | |||
//prompt expect input from the user by showing a small window with space for input to be submitted once called. | |||
What is the return value of `prompt`? | |||
//undefined | |||
//a string - the name entered my the user. |
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.
If you were writing a program that uses prompt()
to ask for an input value, how can
your program tell if the user clicked "OK" or "Cancel"?
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.
when clicking ok it displays a string if the user entered a value otherwise, it leads to an empty string. when clicking cancel it displays null.
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.
Both console.log("null")
and console.log(null)
can result in null appearing in the console.
Instead of focusing on the console output, it's clearer to explain what prompt()
actually returns.
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.
To be honest, I don't know how to answer this apart from the fact that when ok clicked the user's input is returned otherwise in cancellation null is returned.
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.
The term "display" in your original comment suggested you are referring to the values output by console.log()
in the console.
Returns is the standard technical term for what a function "generates". It aligns with programming language terminology.
Your latest description is correct.
when ok is clicked the user's input is returned otherwise in cancellation null is returned
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.
Thanks CJ!
@@ -16,7 +16,7 @@ Try also entering `typeof console` | |||
Answer the following questions: | |||
|
|||
What does `console` store? | |||
//console doesn't store. it displays. | |||
//it stores different logging, debugging, warning/errors and information properties. |
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.
What are these logging, debugging, ... properties? Are they numbers, strings, or ....?
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.
They are indeed properties - Pairs of keys and their corresponding values.
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.
Saying "console
is an object that stores ... properties" is too vague; it doesn't explain what kind of properties they are or what they do. Are they storing numbers, strings, or something else? It would be more helpful to clarify what these properties actually represent. Can you provide more detail about them?
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.
Done. Hopefully, my response is sufficient now.
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.
Describing code can be quite challenging at first (even in your native language).
Knowing the proper terminologies is important.
That's why I keep suggesting using ChatGPT to explore alternative ways to describe code. Along the way, you might also pick up some useful programming terminology.
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.
Noted. Really appreciate your feedback :)
Learners, PR Template
Self checklist
Changelist
This pull request includes the coursework for Sprint 1 of the Module: Structuring and Testing Data.
Questions
Ask any questions you have for your reviewer.