Estimating Cost
LLM pricing is quoted per million tokens. To budget a feature you convert a token count into dollars:
cost = (tokens / 1,000,000) Γ pricePerMillion
Your task
Write costDollars(tokens, pricePerMillion) returning the cost in dollars,
rounded to 4 decimal places.
β‘ 35 XP
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
1M tokens at $3
500k at $10
zero tokens
Run your code to check these.