JSFiddle - React, Tailwind, and code Playground
by not important
HTML
<script src="//searls.github.io/jasmine-all/jasmine-all-min.js"></script>
CoffeeScript
# stock trade max profit finder
prices =
maxProfitFinder = (prices) ->
throw 'prices array must have at least 2 entries' if prices.length < 2
minPrice = prices[0]
maxProfit = prices[1] - minPrice
for price, index in prices
continue if index is 0
potentialProfit = price - minPrice
maxProfit = Math.max(maxProfit, potentialProfit)
minPrice = Math.min(minPrice, price)
maxProfit
describe 'maxProfitFinder', ->
it 'works', ->
prices = [
100
99
103
98
100
130
90
]
expect(maxProfitFinder prices).toEqual 32