I am working in a button component and the bolded portion of the code below displays the error “Unexpected token $”. I am not sure how to format the idea I have. I want to this code to be reusable in future slides, where all I have to do is set the number of attempts and then the rest of the code is generalized to work in reference to that variable.
How do I format it so that the button changes to red on their last attempt?
#Set number of attempts students get
attempts=3
#Disables button after certain number of attempts
disabled: this.pressCount=attempts
#Displays number of attempts remaining
label: " ({numericValue("{attempts}-${this.pressCount}“)} attempts left)”
#changes color of button after certain number of attempts
style:
when this.pressCount >= ${attempts}-1 buttonStyles.red
otherwise buttonStyles.default