Skip to content

Commit fefb3d9

Browse files
committed
changed 5 to number, made Boolean false, made 25 a number
1 parent 6a2d054 commit fefb3d9

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

main.js

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
/*
22
3-
Objective:
4-
In this activity, you will reinforce the skill of creating and using variables
5-
while practicing best practices in variable naming conventions through a hands-on,
6-
interactive coding challenge.
7-
8-
The code snippet below may include:
9-
- Ambiguous or incorrect variable names.
10-
- Missing variables that need to be created.
11-
- Scenarios that require the use of clear and descriptive variable names.
12-
13-
You will:
14-
- Identify Issues: Review the provided code and identify any variable names that:
15-
- Are unclear or too vague (e.g., a, b, c).
16-
- Do not follow best practices (e.g., camelCase, descriptive naming).
17-
- Refactor the Code: Rename the variables and rewrite the program using descriptive names that clearly convey the variable's purpose.
18-
- Enhance the Program: Add at least two additional variables to improve the program’s functionality or clarity.
19-
20-
Things to reflect on:
21-
- Why is it important to use meaningful variable names?
22-
- What are the common pitfalls to avoid when naming variables?
23-
- How do clear variable names benefit team collaboration?
24-
3+
Part 1: Debugging Challenge
4+
The JavaScript code below contains intentional bugs related to type conversion.
5+
Please do the following:
6+
- Run the script to observe unexpected outputs.
7+
- Debug and fix the errors using explicit type conversion methods like Number() , String() , or Boolean() where necessary.
8+
- Annotate the code with comments explaining why the fix works.
9+
10+
Part 2: Write Your Own Examples
11+
Write their own code that demonstrates:
12+
- One example of implicit type conversion.
13+
- One example of explicit type conversion.
14+
15+
*We encourage you to:
16+
Include at least one edge case, like NaN, undefined, or null .
17+
Use console.log() to clearly show the before-and-after type conversions.
18+
2519
*/
2620

27-
let name = "Alice";
28-
let itemType = "steaks";
29-
let amountOfItems = 5;
30-
let price = 20;
31-
let store = "the grocery store";
32-
let shoppingTrip = (name + " bought " + amountOfItems + " " + itemType + " for $" + price + " at " + store + ".");
3321

34-
console.log(shoppingTrip);
22+
let result = Number("5") - 2; //made 5 a number since it was already doing a subtraction.
23+
console.log("The result is: " + result);
24+
25+
let isValid = Boolean("false");
26+
if (isValid) {
27+
console.log(Boolean(false)); // made boolean false in console.log to get is valid to be false
28+
}
29+
30+
let age = Number("25"); // made 25 a number so that total agae would be 25 plus 5 to be 30 instead of 255.
31+
let totalAge = age + 5;
32+
console.log("Total Age: " + totalAge);

origin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit ce929424bb1e79d18dd5c2a834bdf8326d3629d5
Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)