# Having difficulty debugging code

Trying to set up a screen with infinite practice for students to divide integers.
Code works for screen 16 - 18 but not screen 23. Can’t find the error.
I’m very new to desmos CL so I’m modifying others work and I have bit off more than I can chew I think. I copied screen 22 where the code is working for multiplying integers but for screen 23 I can’t get the code to create the fraction.

Just a couple things to adjust in order to display as a fraction. Include a backslash before frac in your expression variable.

expression =  "\frac{${r1}}{${r2}}"


For the content sink, use this as your “otherwise.” You had an extra set of backtick marks there as well as an extra backslash.

"Simplify:\n\n${expression}"  I didn’t have time to look at the multiplication slide, but if everything was working as intended there, you could use the code for that slide to help with the division slide too. I’m guessing you want the answers to be integer values, so you could reverse engineer the code to help with that. If you multiply the two randomly generated numbers, use the product as the dividend in your division problem. The divisor can be the r1 variable and the quotient can be the r2 variable. 1 Like I added a backslash to expression, and you had extra backticks in content. Excellent. That worked great. New problem, if the fraction generated is -3/12 it won’t accept -1/4 as the answer. Sorry for the delayed response…I made some adjustments to get the solutions to be accepted, but I changed it so that only integer solutions exist. It becomes more complicated when you are looking for simplified fractions (it’s possible, I just didn’t have time to explore). I also noticed that sometimes you were given a problem like 2/7 and no calculation was even necessary. Anyway, here’s the code you can use for the note. in = DivInput n = DivNote r = randomGenerator(in.submitCount) r1 = numericValue("(-1)^${r.int(0,1)}*${r.int(2,30)}") r2 = numericValue("(-1)^${r.int(0,1)}*${r.int(2,15)}") expression = "\frac{${dividend}}{${r2}}" dividend = numericValue("${r1}*${r2}") content: when in.timeSinceSubmit > 0 "${result}\n\n\Click to try another." otherwise "Simplify:\n\n${expression}" result = when in.lastValue("correct") = 1 "\n\Question: \frac{${dividend}}{${r2}}\n\n\Solution: ${solution}\n\n\✔Correct! 😎" otherwise "\n\Question: \frac{${cr3}}{${cr2}}\n\n\Solution: ${solution}\n\n\❌Incorrect. ☹️" cr1 = in.lastValue("r1") cr2 = in.lastValue("r2") cr3 = in.lastValue("r3") solution=cr1  And this line can be changed on the input. capture("correct"): when this.numericValue=note.script.r1 1 otherwise firstDefinedValue(numericValue("-${g.number("c_{urrent}")}"),0)


Thanks for all your help. I will try this out later.

S.