← Back to challenges

Is the Sequence Linear, Quadratic or Cubic?

JavaScriptHardrecursionalgorithmsmath

Instructions

Create a function that determines if a given sequence is linear, quadratic or cubic. The input will be an array of numbers of varying lengths. The function should return "Linear", "Quadratic" or "Cubic".

Examples

seqLevel([1, 2, 3, 4, 5]) ➞ "Linear"

seqLevel([3, 6, 10, 15, 21]) ➞ "Quadratic"

seqLevel([4, 14, 40, 88, 164]) ➞ "Cubic"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.