0

I am working on a complex array in which questions and its related answers are coming from the service. After receiving the array I want to change the attribute 'IsChecked' of the Answers to false. My code for this is

this.questions.forEach( elm => {
                  elm.Awnsers.forEach( ans => {
                    ans.IsChekced = false;
                  });
                });

and the output coming is

{Awnser: "Periapical radiograph(s).", IsChecked: true, Qid: 1, IsChekced: false}

As you can see instead of changing the value of IsChecked the code is adding another attribute with the same name. What is wrong am I doing?

2
  • IsChekced is the wrong key please change it IsChecked. please check the answer for detail Commented Mar 13, 2019 at 4:33
  • if you think our solution solved your problem then you accept the answer so that others will get benefit out of it thanks! Commented Mar 13, 2019 at 5:25

3 Answers 3

1

I think you misspelled the IsChecked key with IsChekced

Just update below code it will work.

this.questions.forEach( elm => {
                  elm.Awnsers.forEach( ans => {
                    ans.IsChecked= false;
                  });
                });

Hope this will help

Sign up to request clarification or add additional context in comments.

Comments

1

IsChekced is spelled incorrectly. It is not IsChecked

k <==> c

Comments

0

Yes you just misspelled the IsChecked you can do this by below code

this.questions.forEach( elm => {
    elm.Awnsers.forEach( ans => {
      ans.IsChecked = false;
    });
  });
  console.log(this.questions);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.