Code for Desmos to accept both y = 3x + 13 and y = 13 + 3x as correct?

I am trying to create self-checking slides for solving literal equations, and I am using code from other slides I’ve found. I can figure out how to get Desmos to accept one form of an answer, but can someone help me with the coding to get equivalent forms of a solution to be accepted? The question is, "Solve y - 3x = 13 for y. I want the accepted answers to be y = 3x + 13 and y =13 +3x.

My code for a single answer is as follows:

correct = this.latex = “y=13+3x”

correct: correct

How would I alter the code so that y=3x+13 is also considered correct?

Welcome to our community!

If these are the only two answers you would consider correct, then you could change your code to

correct = this.latex = `y = 13 + 3x` or this.latex = `y = 3x + 13`

Note that by using backticks rather than quotation marks, students could type additional spaces in their answers and this would not affect correctness.

If you wanted a more robust solution (e.g. if you would allow an answer like y = 3(x + 4) + 1) then you could use xyLine(this.latex) to check the slope and intercept, and then use parseEquation(this.latex) to check the left hand side consists just of y.

1 Like