# How to check numeric value in a table cell

Hope I can get some help! In cellContent(2,2) and cellContent(2,4), I want to be able to check the numerical value the students input instead of having to write every version of the answer as a check.
Is there a way to use numericValue to do that in a table cell? I am a very beginner level programmer and have been trying to figure this out for quite some time. Any help would be greatly appreciated!
Here is the code that I have created for Slide 1 of

correct: this.cellContent(1,1)=“” and this.cellContent(1,3) =“” and this.cellContent(2,1)=“” and this.cellContent(2,3)=“

cellContent(1,2):
when this.cellContent(1,1) =“\frac{\left(-4+5\right)}{2}” “
otherwise “”

cellContent(1,4):
when this.cellContent(1,3) =“\frac{\left(4±1\right)}{2}” “
otherwise “”

cellContent(2,2):
when (this.cellContent(2,1) =“0.5” or this.cellContent(2,1)=“.5” or this.cellContent(2,1)=“\frac{1}{2}”) “
otherwise “”

cellContent(2,4):
when this.cellContent(2,3) =“” “
otherwise “”

cellDisableEvaluation(1,1): true
cellDisableEvaluation(1,3): true
cellDisableEvaluation(2,1): true
cellDisableEvaluation(2,3): true

Hi!
You absolutely can use cellNumericValue, but this will accept any format of answer. For example, if students typed (-4 + 5)/2 in the bottom left cell, it still gets marked correct. Checking the format of a student’s answer is more advanced and uses the patterns library. If you’re curious to learn more, Desmos has a YouTube playlist introducing patterns.

Here is a copy of your activity with cellNumericValue and a pattern match used to check the bottom left cell: [Copy of] Midpoint Formula 1 • Activity Builder by Desmos

The relevant code is

# decimalOrFraction checks if students entered a decimal value (the "number" pattern) or a fraction with a decimal value in the numerator and denominator
p = patterns
decimalOrFraction = p.anyOf(p.number, p.fraction(p.number, p.number))

cellContent(2,2):
when (
this.cellNumericValue(2, 1) = 0.5 # correct value
and decimalOrFraction.matches(this.cellContent(2, 1)) # correct format
) "✔"
otherwise ""


I hope this helps!

Yes, thank you so much! This is exactly what I needed! I will definitely have to check out that playlist, I had a feeling that this solution would be more complex than my realm of understanding code. Thanks again!