This is a solution to the Order summary card challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Note: Delete this note and update the table of contents based on what sections you keep.
Users should be able to:
- Interact with the buttons on the page.
- Solution URL: [https://www.frontendmentor.io/solutions/order-summary-component-WP0kYuycV]
- Live Site URL: [https://jialeee17.github.io/order-summary-component-main/]
- HTML5
- CSS3
- SCSS pre-processor
- JavaScript
- Mobile-first workflow
- RWD Concept
In this challenge, I tried to apply some of the very basic logics using JavaScript to make the website more interactive. For example, the input validation which only allows number as input from users. Also, I wrote a random digits generator for generating order number.
let your_pocket_depth;
const regex = /\D/gi;
// Amount validation
your_pocket_depth = prompt('How much money do you have?');
if (your_pocket_depth.match(regex)) {
do {
window.alert('Please enter valid amount. Don\'t fool me!');
your_pocket_depth = prompt('How much money do you have?');
} while (your_pocket_depth.match(regex));
}
if (parseInt(your_pocket_depth) > 100) {
const order_number = Math.floor(100 + Math.random() * 900);
window.alert(`Your order ${order_number} has been processed!`);
}
I will give it a try to apply more advanced JavaScript logics in the future projects. Stay tuned!