bitcoin tracker

by jasonvee

JavaScript

// Declare variables.  
//This creates variables and clears them back to 0 for next time the program runs
var dollars_start = 0;
var bitcoin_cost = 0;
var how_many_bitcoins = 0;
var bitcoin_worth_when_sold = 0;
var dollars_finish = 0;
var profit_or_loss = 0;

//Work out how many bitcoins they user had when they bought
dollars_start = prompt('How many dollars worth of Bitcoin did you buy? ');
bitcoin_cost = prompt('What was 1 bitcoin worth when you bought it? ');
how_many_bitcoins = dollars_start / bitcoin_cost
document.write('You had ' + how_many_bitcoins + ' bitcoins when you bought' + '<br>');

//how many dollars when sold 
bitcoin_worth_when_sold = prompt('What was bitcoin worth when you sold it? ');
dollars_finish = how_many_bitcoins * bitcoin_worth_when_sold

document.write('You had ' + dollars_finish + ' dollars when you sold')