-
-
Notifications
You must be signed in to change notification settings - Fork 195
Module-Structuring-and-Testing-Data | Sprint-1 #528
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
82cec5d
6467880
e6e9e18
0a92387
ebbab63
57c9692
e13f3e7
cb7e0cf
cac529e
325d551
ec31455
18243e2
d580b92
a9b1745
f506dd3
652a66b
d0bb7dc
0cbc5ad
5362c2f
5914b8a
180d914
e99ba2d
bce7a36
b4b63e6
b03d5c1
46e7933
36e0def
2d81ea8
624683e
be9bde8
8a282aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
let count = 0; | ||
|
||
count = count + 1; | ||
|
||
|
||
// 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 | ||
|
||
|
||
///answer line3 is a statement that increases count by 1. the =operator reassigns the result of count +1 back to the count variable |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
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 don't want the computer to run these 2 lines - how can we solve this problem? | ||
|
||
we use // at the beginning of the line | ||
we wrap it with /**/ if it spans multiple | ||
|
||
Comments are ignored by the JavaScript engine — they're only for humans to read, like notes or documentation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
// Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
// what's the error ? | ||
|
||
// Currently trying to print the string "I was born in Bolton' but it is not working... | ||
// What is the error? | ||
// | ||
console.log(`I was born in ${cityOfBirth}`); | ||
const cityOfBirth = "Bolton"; | ||
|
||
// here we first declare cityOfBirth before using it to avoid error | ||
|
||
// | ||
" |
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. can you explain the change you made here? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const 24hourClockTime = "08:53"; | ||
|
||
|
||
|
||
//output the values | ||
|
||
|
||
|
||
console.log("Clock time in 12h format:", clockTime_12Hour); | ||
|
||
|
||
console.log("Clock time in 24h format:",clockTime_24Hour); | ||
|
||
|
||
|
||
|
||
|
||
|
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 answer, I think you mixed up question d) with e) and are missing an answer. Could you identify the variable declarations? |
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 here |
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 analysis |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,15 @@ In the Chrome console, | |
invoke the function `alert` with an input string of `"Hello world!"`; | ||
|
||
What effect does calling the `alert` function have? | ||
// i run alert("Hello World!"); | ||
// A box pop up in the browser window with the message:Hello World! | ||
//It has an "OK" button that i must click to dismiss the alert | ||
|
||
Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. | ||
|
||
What effect does calling the `prompt` function have? | ||
What is the return value of `prompt`? | ||
|
||
//const myName = prompt("What is your name?"); | ||
//a modal box appears with the message "What is your name?" | ||
//there are OK AND Cancel buttons | ||
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 exploration - did you manage to find what the return value could 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. good answer |
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 explanation, can you provide some new code that works correctly? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
|
||
// The code will throw an error because the variable `str` is being declared twice in the same scope. | ||
|
||
// 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; | ||
} | ||
capitalise("hello,this is a test"); | ||
|
||
// | ||
|
||
// =============> write your explanation here | ||
// =============> write your new code here | ||
//// The error occurs because the variable `str`is declared twice in the same scope,which is not allowed in JavaScript. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,28 @@ | |
|
||
// =============> write your prediction of the error here | ||
|
||
//we will get an error bcs the parameter of the function need to string type not number so it can be something like num | ||
|
||
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. Could you explain what you mean by the parameter needing to be a string type? |
||
function square(3) { | ||
return num * num; | ||
} | ||
|
||
// =============> write the error message here | ||
//Output: | ||
|
||
/index.js:1 | ||
function square(3) { | ||
^ | ||
|
||
SyntaxError: Unexpected number | ||
// =============> explain this error message here | ||
|
||
// Finally, correct the code to fix the problem | ||
|
||
// =============> write your new code here | ||
|
||
|
||
//THe error message tells that we wrote a syntax that JavaScript does not understand. | ||
function square(num) { | ||
return num * num; | ||
} | ||
result = console.log(square(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.
Be careful about reassigning variables - you've reused the
dir
andext
constants here