Skip to content Skip to sidebar Skip to footer

How To Get Text By Id From Array? React

CurrentUserAnswerVariants: {id: '4468cdc8-220d-4634-9d68-6c9920e0cb48', text: 'Question 1', minAnswersQuantity: 1, maxAnswersQuantity: 1, canComment: false, canComm

Solution 1:

functionidEquals(idToCompare, question) {
    return question.id.indexOf(idToCompare) === 0;
}

currentUserAnswerVariantsVariantIds = question.filter(idEquals.bind(this, currentUserAnswerVariants));

Does this work? It's something along these lines, and you may edit the following code accordingly.

Solution 2:

  1. $var = $('#id').val();
  2. $var['text']; -> only if you need single id text

-> or use foreach on id and push the each result into one blank array and print array

Post a Comment for "How To Get Text By Id From Array? React"