Last week I wrote about trying to to hold myself accountable when it comes to writing more blog posts. My previous post said I promised to write out some pseudocode for the Tip Calculator JavaScript project I was working on.
To refresh, I took this project from https://fun-javascript-projects.com/ (this course was made and offered by Twitter user @chrisdixon161). Check the free course out as it offers some great practice for using JavaScript.
Let’s take a look below at the end results of the project to see what we’re looking at and what sort of functionality we need.
Side note, for the sake of this article let’s assume we already have the HTML and CSS written out before we begin the pseudocode.
We need to be able to enter a bill amount, the percentage of tip, the tip value, and the total of the bill plus the tip value. We also need to know how many people to split the bill amongst, the bill total for each, and the tip amount for each.
The beauty, or ugliness depending on how you want to look at it, of using pseudocode is that there is no right or wrong way to write it.
Here’s my stab at writing out the very basics of what we need in our eventual JavaScript code:
- INPUT bill amount
- STORE bill amount in BILL variable
- OUTPUT BILL
- INPUT tip percent
- STORE tip percent in TIP PERCENT variable
- OUPUT TIP PERCENT
- OUTPUT tip value in dollars
- OUTPUT total (bill + tip) in dollars
- INPUT number of people to split the bill
- STORE number of people to split the bill in SPLIT variable
- OUTPUT SPLIT
- OUTPUT bill total for each person
- OUTPUT tip for each person
This is just a very quick breakdown of what I need to get started. Once I have written out the actual JavaScript code for the above pseudocode then I can start figuring out how to make it all function.
For me, the whole process of where to start when it comes to writing JavaScript is a difficult task. Do you think using pseudocode is beneficial? What helps you plan out your JavaScript (or any other programming language)? How would you go about writing pseudocode for this Tip Calculator? I’d love to hear from you!!!
Top comments (1)
😅😅 I really don't consider pseudo code when it's comes to my project
I focus more on the user story
But it such comes in handy when it's a group project