Graph function from a table using n as variable

Hello there.

I want to have my students graph a function from a table, but they would be using the variable “n” instead of “x”. The code I have works for 2x-4, but not for 2n-4.

function("f"): simpleFunction(table27.cellContent(3,2))

And within the graph I have tried both y=f(x) and y=f(n).

Any help appreciated,

simpleFunction automatically defaults to an input variable of x if not specified, so you can just pass a second argument like this:

function(`f`): simpleFunction(table27.cellContent(3,2), `n`)

If you’d like in the table, you can use an errorMessage to alert students in case they attempt to use x instead of n.

cellErrorMessage(3,2): when isUndefined(simpleFunction(this.cellContent(3,2), `n`)) "Write a function using n as the independent variable." otherwise ""

It worked! Thank you :slight_smile: