-
-
Notifications
You must be signed in to change notification settings - Fork 116
ITPJan | KATARZYNA KAZIMIERCZUK | STRUCTURING AND TESTING DATA | SPRINT1 #431
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
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 |
---|---|---|
|
@@ -17,7 +17,12 @@ console.log(`The base part of ${filePath} is ${base}`); | |
// Create a variable to store the dir part of the filePath variable | ||
// Create a variable to store the ext part of the variable | ||
|
||
const dir = ; | ||
const ext = ; | ||
|
||
// dir: The part of the path before the last slash (/), which represents the directory. | ||
// base: The file name with the extension, which is everything after the last slash (/). | ||
// ext: The file extension, which is the part after the last period (.) in the base file name. | ||
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 explanations |
||
|
||
const dir = filePath.slice(0, lastSlashIndex); | ||
const ext = base.theLastIndexOf('.'); | ||
|
||
// https://www.google.com/search?q=slice+mdn |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,10 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | |
// Try breaking down the expression and using documentation to explain what it means | ||
// It will help to think about the order in which expressions are evaluated | ||
// Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
console.log(num) | ||
|
||
//gets a random number between 1 and 100 | ||
//math.floor random float between 0 and 1, < 1 | ||
//math.floor round down to int | ||
// + 1 to inlude max value so 100 | ||
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 step by step comments 👍 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
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? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
// trying to create an age variable and then reassign the value by 1 | ||
|
||
const age = 33; | ||
age = age + 1; | ||
// const age = 33; | ||
let age = 33; | ||
// age = age + 1; | ||
age = age ++; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
// 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}`); | ||
// console.log(`I was born in ${cityOfBirth}`); | ||
// const cityOfBirth = "Bolton"; | ||
|
||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
|
||
// const last4Digits = cardNumber.slice(-4); | ||
|
||
// The last4Digits variable should store the last 4 digits of cardNumber | ||
// However, the code isn't working | ||
// 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 | ||
|
||
// slice works on strings, not integers | ||
|
||
const last4Digits = cardNumber.toString().slice(-4); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const 24hourClockTime = "08:53"; | ||
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. Have you noticed the errors here? Try running this file and see what happens 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. fixed |
||
|
||
//there are no instructions here |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ let carPrice = "10,000"; | |
let priceAfterOneYear = "8,543"; | ||
|
||
carPrice = Number(carPrice.replaceAll(",", "")); | ||
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); missing , | ||
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); | ||
|
||
const priceDifference = carPrice - priceAfterOneYear; | ||
const percentageChange = (priceDifference / carPrice) * 100; | ||
|
@@ -12,11 +13,12 @@ console.log(`The percentage change is ${percentageChange}`); | |
// Read the code and then answer the questions below | ||
|
||
// a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
|
||
//3 | ||
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. What lines do you think are using a function call? 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.
4 twice, 6 twice, 11 |
||
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? | ||
|
||
// 4 | ||
// c) Identify all the lines that are variable reassignment statements | ||
|
||
// 4, 6 | ||
// d) Identify all the lines that are variable declarations | ||
|
||
// 1, 2, 8, 9 | ||
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
// replace all instances a , with "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const movieLength = 8784; // length of movie in seconds | ||
// const movieLength = 8784; // length of movie in seconds | ||
const movieLength = -2; // length of movie in seconds | ||
|
||
const remainingSeconds = movieLength % 60; | ||
const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
@@ -12,14 +13,15 @@ console.log(result); | |
// For the piece of code above, read the code and then answer the following questions | ||
|
||
// a) How many variable declarations are there in this program? | ||
|
||
// 6 | ||
// b) How many function calls are there? | ||
|
||
// 0 | ||
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. Would we count 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. yes we do, my error |
||
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
|
||
// it calculates whats the reminder of dividing total minutes by 60 | ||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
|
||
// it calculates the length fof the movie minus seconds divided by 60 to get the total time in minutes | ||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
||
//leftToPlay | ||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
// it doesn not produce the correct result for a negative value |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,18 @@ test("should identify right angle (90°)", () => { | |
expect(getAngleType(90)).toEqual("Right angle"); | ||
}); | ||
|
||
// REPLACE the comments with the tests | ||
// make your test descriptions as clear and readable as possible | ||
|
||
// Case 2: Identify Acute Angles: | ||
// When the angle is less than 90 degrees, | ||
// Then the function should return "Acute angle" | ||
test("should identify acute angle (< 90°)", () => { | ||
expect(getAngleType(60)).toEqual("Acute angle"); | ||
}); | ||
|
||
// Case 3: Identify Obtuse Angles: | ||
// When the angle is greater than 90 degrees and less than 180 degrees, | ||
// Then the function should return "Obtuse angle" | ||
test("should identify obtuse angle (> 90° < 120°)", () => { | ||
expect(getAngleType(111)).toEqual("Obtuse angle"); | ||
}); | ||
|
||
// Case 4: Identify Straight Angles: | ||
// When the angle is exactly 180 degrees, | ||
// Then the function should return "Straight angle" | ||
test("should identify straight angle (180°)", () => { | ||
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 use of testing! |
||
expect(getAngleType(180)).toEqual("Straight angle"); | ||
}); | ||
|
||
// Case 5: Identify Reflex Angles: | ||
// When the angle is greater than 180 degrees and less than 360 degrees, | ||
// Then the function should return "Reflex angle" | ||
test("should identify reflex angle (> 180° < 360°)", () => { | ||
expect(getAngleType(181)).toEqual("Reflex angle"); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
numerator = numerator < 0 ? Math.abs(numerator) : numerator; | ||
let result = numerator < denominator ? true : false; | ||
return result; | ||
} | ||
// or shorter return numerator < denominator because it already returns a boolean | ||
|
||
module.exports = isProperFraction; |
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 explanation!