JSFiddle - React, Tailwind, and code Playground

by taa1953

JavaScript

const MAX_ROWS = 12;
const K = 5;
var i,
  stockPrice = 50,
  volatility = 30 / 100,
  change,
  prices = [];
  
  prices[0] = stockPrice;


change = ((1 + (volatility / K)) * stockPrice) - stockPrice;
console.log(change);

for (i = 1; i < MAX_ROWS; i += 1) {
  prices[i] = prices[i - 1] + change;
  console.log(prices[i]);
}