Table correctness based on student created inputs

I know how to create a table that checks for correctness, and normally use a code similar to this:

figure1number = table4.cellNumericValue(1,3)

initialCellContent(1,4): when figure1number =4 “:white_check_mark:” otherwise “”

cellEditable(1,4): false

What I need help on is the following: I want to write a function in the note, something like f(x)=2x and then have the students fill in input output values that work in the table, like (1,2).

how can I get the table to check for something like this:

figure1number = table4.cellNumericValue(1,2)
figure2number = table4.cellNumericValue(1,3)

initialCellContent(1,4): when figure2number =2*(figure1number) “:white_check_mark:” otherwise “”

cellEditable(1,4): false

this currently doesnt work, but is there a way to do something similar? so that they can write any pair they can imagine, and the table will still be able to check for correctness by taking their input for the x value, fun it through the function, and make sure the y value matches what it should.

You can do that with simpleFunction and evaluateAt. Another suggestion that will save you a bit of time is try using cellContent instead of initialCellContent. The main difference is initial makes the cell editable, so then you don’t need to use the cellEditable sink!

figure1number = this.cellNumericValue(1,2)
figure2number = this.cellNumericValue(1,3)
f = simpleFunction("2x")

cellContent(1,4): when figure2number =f.evaluateAt(figure1number) "✅" otherwise ""

That worked perfectly!