Skip to content

Conversation

@AdiAmar1
Copy link

@AdiAmar1 AdiAmar1 commented Dec 6, 2024

No description provided.

@OptimaLPro OptimaLPro assigned OptimaLPro and unassigned OptimaLPro Dec 7, 2024
@OptimaLPro OptimaLPro self-requested a review December 7, 2024 14:16
Comment on lines +48 to +51
<input class="input-box" id="numOfpeople">
<img src="./images/icon-person.svg" class="icon-person">
<!-- <span class="price">5</span> -->
</input>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text cursor inside the input is under the icon.
use padding: 0px 20px; to the input-box, it's should fix it

Comment on lines +29 to +32
<input class="input-box" id="price">
<img src="./images/icon-dollar.svg" class="icon-dollar">
<!-- <span class="price">142.55</span> -->
</input>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text cursor inside the input is under the icon.
use padding: 0px 20px; to the input-box, it's should fix it




let tipAmout;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for notice, you wrote "tipAmout" and called it in row 24 and more as "tipAmount"

Comment on lines +18 to +21
if(!priceValue || !peopleValue || priceValue<=0 || peopleValue<=0){
hoverWarning.style.display="block";
return;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use isNaN(priceValue) and check if the priceValue and peopleValue are numbers, and then show error message accordingly

<p class="white-txt">Tip Amount</p>
<p class="gray-txt">/ person</p>
</div>
<div class="green-price" id="tipRes">$4.27</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure the starting value is $0.00

const priceValue=parseFloat(price.value);
const peopleValue=parseFloat(numOfpeople.value);

if(!priceValue || !peopleValue || priceValue<=0 || peopleValue<=0){
Copy link

@OptimaLPro OptimaLPro Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add that the clicked button will change the background color, something like this idea:

   const buttonElement = document.getElementById(`tip${x*100}`);
    if (buttonElement) {
        buttonElement.classList.add("active");
    }

and make the "active" class with different background color

Comment on lines +31 to +50
customTip=()=> {
const priceValue=parseFloat(price.value);
const peopleValue=parseFloat(numOfpeople.value);
const customValue= parseFloat(custom.value/100);

if(!customValue || customValue<=0){
hoverWarning.style.display="block";
return;
}
hoverWarning.style.display="none";

tipAmount=(priceValue*customValue)/peopleValue;
total=(priceValue*(1+customValue))/peopleValue;


tipAmountResult.innerText="$"+tipAmount.toFixed(2);
totalAmountResult.innerText="$"+total.toFixed(2);
};

custom.addEventListener("blur", customTip);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great functions.
Easy to read,
good technique!

Comment on lines +53 to +56
</div>


<div class="right">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation: Use a single blank line here instead of two. Double blank lines are generally reserved for major separations (e.g., between classes or functions). This keeps the code clean and easier to read.

@OptimaLPro OptimaLPro closed this Dec 7, 2024
@OptimaLPro OptimaLPro reopened this Dec 7, 2024
Copy link

@OptimaLPro OptimaLPro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work overall!
Keep working :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants