Skip to content

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
209ea8f
explained line 3 - variable reassignment
HassanOHOsman May 29, 2025
cf11f38
declared variable stores initial of each word
HassanOHOsman May 29, 2025
9751116
created 2 variables to store different filepathes
HassanOHOsman May 30, 2025
c263fad
Completed Math object * its methods exercises
HassanOHOsman May 30, 2025
8ab5a4e
Commented to avoid running my lines of code
HassanOHOsman May 30, 2025
e8108f8
SyntaxError solved by commenting
HassanOHOsman May 30, 2025
5c1b48b
declaration keyword changed to let to solve error
HassanOHOsman May 30, 2025
2a36aae
ReferenceError avoided by declaring variable first
HassanOHOsman May 30, 2025
064ecb3
last4Digits value updated to avoid error message.
HassanOHOsman May 30, 2025
547fbeb
renamed variables to avoid syntax error
HassanOHOsman May 30, 2025
608f18d
added comma between inputs (line 5) to solve error
HassanOHOsman Jun 2, 2025
47d435e
completed time format
HassanOHOsman Jun 2, 2025
408a4f2
explanation for the code provided
HassanOHOsman Jun 2, 2025
e57e590
V8 questions answered
HassanOHOsman Jun 2, 2025
d1e40e4
answered all questions
HassanOHOsman Jun 2, 2025
b0469be
updated = described line 3
HassanOHOsman Jun 20, 2025
a6e7a48
simplified description - used technical terms
HassanOHOsman Jun 20, 2025
1042135
changed variable names to meet JS requirements
HassanOHOsman Jun 20, 2025
6dd1748
updated answer for variable declaration question
HassanOHOsman Jun 20, 2025
a6bfabe
rephrased my answer for the last question
HassanOHOsman Jun 20, 2025
41eff9e
updated my answer for the last question
HassanOHOsman Jun 20, 2025
d94c7bd
rephrased my answer for Q -f
HassanOHOsman Jun 20, 2025
5203cb7
changed my response to the last question
HassanOHOsman Jun 20, 2025
616652d
changed some of my answers
HassanOHOsman Jun 20, 2025
ec14852
updated response to last question
HassanOHOsman Jun 23, 2025
7c5701d
corrected my response to the 4th Q
HassanOHOsman Jun 23, 2025
c93411c
updated my responses
HassanOHOsman Jun 23, 2025
a9cdc03
updated response for "What does `console` store?"
HassanOHOsman Jun 24, 2025
cac3613
Edited answer 4 What's the return value of prompt?
HassanOHOsman Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ count = count + 1;
// Describe what line 3 is doing, in particular focus on what = is doing

/*
Answer: in line 3, the variable count gets reassigned a new value which is the sum of the old value and 1.
Answer: line 3 shows increment operation - 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.
*/

12 changes: 4 additions & 8 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// Try logging the value of num and running the program several times to build an idea of what the program is doing

/*
1. num represents any random whole number (integer) between 1 and 100 (both included)
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).
1. Since Math.random() returns an integer in the interval [0, 1). This means num eventually represents any random integer in the interval [0, 100].
2. Math.floor() rounds down the expression "Math.random() * (maximum - minimum + 1)"", leading to an integer in the interval [0,100).

3. So num returns an integer in the interval [0,100) + 1 which eventually means num return [0, 100]
4. Done!
*/
4 changes: 2 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

// to avoid the syntax error after running the above lines of code do as below:

const ClockTime12Hour = "20:53";
const ClockTime24hour = "08:53";
const clockTime24Hour = "20:53";
const clockTime12Hour = "08:53";
5 changes: 2 additions & 3 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ this problem.

c) line 4 & line 5

d) line 1 & line 2
d) lines 1, 2, 7 & 8

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.
e) Firstly, it removes all commas in the string and eventually converts the new string into a number.
*/
7 changes: 3 additions & 4 deletions Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const movieLength = -10; // length of movie in seconds
const movieLength = 0; // length of movie in seconds

const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;
Expand Down Expand Up @@ -27,10 +27,9 @@ console.log(result);

/*
a) There are 6 in total.
b) 0 function calls.
b) Only one function call "console.log(result)".
c) it represents the remainder from the division of movieLength by 60.
d) line 4 represents the total number of mins in the movie (as whole numbers -integers) by getting rid of the decimal parts (in secs).
e) Result represents the total movie duration (in exact hours, exact min and exact sec). movieDuration could be a good name.
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.
f) Yes, It does work when trying different values of movieLength.
*/
2 changes: 1 addition & 1 deletion Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

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"?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks CJ!

2 changes: 1 addition & 1 deletion Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

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 ....?

Copy link
Author

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.

Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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 :)

What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
//console.log log or display values to the console. Console.assert, check if a condition is true and in this case no output. Otherwise, an
// error message shows. As for the `,`, it's called the dot notation and it's used to access properties and methods of an object.