tl;dr Students enter 2 values into a table. How do I test to see if the tablevalue is empty/undefined?
I still have a way to go, fixing spacing, directions, etc.
Students will be given a system of 2 equations. Their goal is to select the value that needs to be multiplied by the 1st and 2nd equations so that when we add the equations, one of the variables is canceled out.
In the graph area, you’ll see that I am using labels of points to show the equations. I have the 2 original equations. Then I repeat the 2 equations with (m_a) and (m_b) to show the multiplication.
m_a & m_b are defined by the values students type into the table.
But if they haven’t typed into the table, the equations are showing m_a & m_b as “undefined”. In the CL area for the graph, I’m trying to check for undefined. If m_a is undefined, I want a variable d_a to equal 0. If m_a is defined, I want d_a to be 1. But d_a is equalling 1 even when m_a is not defined.
I’d prefer the value of d_a to update even if students haven’t yet clicked submit.
Maybe there’s a better way to accomplish this instead of using d_a? My thoughts were that I’d create two equations:
**if m_a is undefined, put (?) at the front and end.
**if m_a is defined, put the value of m_a at the front and end.
Sorry, should’ve been clearer. If you’re gonna use number as a source you need a source component. So all together you’d have isUndefined(this.number(“m_a”)). “this” assuming everything is in the same component. If you’re looking up a number in a different component you’ll need to reference that component.
Thank you that worked!
Lesson learned. Even for local variables in the CL, I can’t call “m_a” I need to call this.number(“m_a”) whenever i want to do anything with that.
Now it’s working!
If you don’t actually need it to be a number in the calculator you can just make it m_a = … and then you won’t need to define it as a number in the next section. But yes, if you are defining it as a number in the calculator you need to call on it as such.