-
-
Notifications
You must be signed in to change notification settings - Fork 196
ITP JAN-2025 | ELFREDAH KEVIN-ALERECHI | MODULE STRUCTUREING AND TESTING DATA | WEEK FEBRURAY #423
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
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
let firstName = "Creola"; | ||
let middleName = "Katherine"; | ||
let lastName = "Johnson"; | ||
let firstName = "Elfredah"; | ||
let middleName = "Kevin"; | ||
let lastName = "Alerechi"; | ||
|
||
// Declare a variable called initials that stores the first character of each string. | ||
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
|
||
let initials = ``; | ||
let initials = "firstName[0] + middleName[0] + lastName[0]"; | ||
|
||
// https://www.google.com/search?q=get+first+character+of+string+mdn | ||
|
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,5 +1,9 @@ | ||
// 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}`); | ||
const cityOfBirth = "Bolton"; | ||
//The error occurs because you are trying to use the variable cityOfBirth before it is defined. | ||
// In JavaScript, the line const cityOfBirth = "Bolton"; | ||
// needs to run before you try to use cityOfBirth in the console.log() statement. See the corrected code below: | ||
|
||
const cityOfBirth = "Bolton"; // First, define the variable | ||
console.log(`I was born in ${cityOfBirth}`); // Then, use it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
const last4Digits = cardNumber.slice(-4); // This will throw an error | ||
|
||
// 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 | ||
|
||
//The code will not work because cardNumber is a number, and the .slice() method is used for strings, not numbers. | ||
// The .slice() method cannot be used directly on a number, which will lead to an error. | ||
//TypeError: cardNumber.slice is not a function. | ||
//This happens because .slice() is a method that only works on strings and arrays, but cardNumber is a number. | ||
// You can't call .slice() on a number. | ||
//To fix this, we need to convert the number to a string before using .slice() to extract the last 4 digits: | ||
|
||
const cardNumber = 4533787178994213; | ||
const last4Digits = String(cardNumber).slice(-4); // Convert to string first | ||
console.log(last4Digits); // This will output "4213" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
|
||
const twelveHourClockTime = "20:53"; // Use letters instead of starting with a number | ||
const twentyFourHourClockTime = "08:53"; // Use letters instead of starting with a number | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// =============> I feel the spring will count 0 to 1 | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
// There is an error message that say the 'str' has already been declared. | ||
|
||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
|
||
capitalise("elfredah") | ||
// =============> write your explanation here | ||
// =============> write your new code 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. can you write new code as well for capitalise function |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
// Predict and explain first... | ||
|
||
// =============> write your prediction here | ||
// =============> The program will throw an error when it runs. Specifically, it will result in a SyntaxError or ReferenceError | ||
|
||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// =============> The error happens because the function multiply(a, b) doesn't return a value, so the console.log() statement is trying to print undefined to the console. This is because the function doesn't have a return statement, so it returns undefined by default. | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
// =============> function multiply(a, b) { | ||
//return a * b; | ||
//} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
|
||
// =============> The code is trying to return the sum of two numbers, but it will throw an error when it runs. Specifically, it will result in a SyntaxError or ReferenceError | ||
function sum(a, b) { | ||
return; | ||
a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// =============> The code is trying to sum two numbers, but it will throw an error when it runs. Specifically, it will result in a SyntaxError or ReferenceError. This is because the return statement is followed by a semicolon, which ends the statement and prevents the code after it from running. This means that the function doesn't return a value, so it returns undefined by default. | ||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
// =============> function sum(a, b) { | ||
return a + b; // Ensure the return statement is on the same line as the expression | ||
//} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,14 +43,17 @@ assertEquals(acute, "Acute angle"); | |
// When the angle is greater than 90 degrees and less than 180 degrees, | ||
// Then the function should return "Obtuse angle" | ||
const obtuse = getAngleType(120); | ||
// ====> write your test here, and then add a line to pass the test in the function above | ||
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. please write other condisitons inside of getangleType function as well. |
||
// ====> const obtuse = getAngleType(120); | ||
//assertEquals(obtuse, "Obtuse angle"); | ||
|
||
// Case 4: Identify Straight Angles: | ||
// When the angle is exactly 180 degrees, | ||
// Then the function should return "Straight angle" | ||
// ====> write your test here, and then add a line to pass the test in the function above | ||
// ====> const straight = getAngleType(180); | ||
//assertEquals(straight, "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" | ||
// ====> write your test here, and then add a line to pass the test in the function above | ||
// ====> const straight = getAngleType(180); | ||
//assertEquals(straight, "Straight angle"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,11 @@ assertEquals(aceofSpades, 11); | |
// When the function is called with such a card, | ||
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). | ||
const fiveofHearts = getCardValue("5♥"); | ||
// ====> write your test here, and then add a line to pass the test in the function above | ||
// ====> function getCardValue(card) { | ||
// const rank = card[0]; // Extracts the first character (rank) from the card string | ||
// if (!isNaN(rank)) return Number(rank); | ||
//} | ||
|
||
|
||
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. getCardValue function is not working as expected. Please integrate desired logic inside of the function |
||
// Handle Face Cards (J, Q, K): | ||
// Given a card with a rank of "10," "J," "Q," or "K", | ||
|
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.
you can also use age +=4