Is the Sequence Linear, Quadratic or Cubic?

Published by Mubashir Hassan in

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

Watch a quick demo on how Edabit works.