Profit or loss on your stock?

Profit or loss on your stock?

An application that can tell you your loss and profit on the share market. But make sure that, your profit and loss is more than 50% of the money

Stack used to build this project

  • HTML
  • CSS
  • JavaScript

Use guide

  • Take the user's stock purchase price.
  • Take the stock quantity.
  • Take the current price of the stock.

GiHub

Live link

Explanation

This project is divided into the following steps to understand in a better way.

Step 1: In the first step write the HTML part of the project.

code.png

Step 2: In the second step styling your project using CSS (Cascading Style Sheets).

Step 3: Select form and input filed using this method

document.querySelector(" ")

code.png

Step 4: Attach a submit event to the form element. When the user submits the form, the code would be executed. By using

addEventListener('event', function())

code.png

Step 5: Used preventDefault() method to prevent from submitting a form. ( It block the default action on clicking on the button )

code.png

Step 6: Now, take the value of the user's Purchase price of a stock, Current price of a stock, and quantity of stock to store in a variable. Using the Number() function to convert into number type.

code.png

Step 7: Now, check the purchase price, stock quantity, and the current price is greater than zero using

if-else statement

code.png

Step 8: Now find total loss and total loss in %? And also check that, if you lose more than 50%, you'll get a message visually (GIF).

code.png

code.png

Step 9: And, find total profit and total profit in %? And also check that, if you gain more than 50%, you'll get a message visually (GIF) too.

code.png

code.png

Thank You.