Skip to content

Practice 1 : Code Correction #4

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions variables-naming-conventions-and-top-to-bottom-code-evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@ let c = 20;
let d = a + " bought " + b + " items for $" + c + ".";

console.log(d);

let customerName = "Alice";
let numberOfItems = 5;
let itemPrice = 20;
let totalCost = numberOFItems * itemPrice;
console.log(customerName + " bought " + numberOfItems + " items for" + totalCost + "dollar" + ", each item is $" + itemPrice + ".");

Things to reflect on:

- Why is it important to use meaningful variable names?

Variables are important to have a better understanding of the purpose of codes for developers.

- What are the common pitfalls to avoid when naming variables?

Using vague names, making names too long, mixing styles, using reserved words like function, giving misleading names.

- How do clear variable names benefit team collaboration?

it makes code easier to understand, and it reduces mistakes.