Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  170] [ 5]  / answers: 1 / hits: 28321  / 11 Years ago, wed, november 20, 2013, 12:00:00

I have three arrays:




  • arr1=[14,16,1] — where I am selecting

  • arr2=[14] — where I am comparing my selection from arr1

  • arr3=[] — where I am pushing the value.



How will I be able to check if my selection does not exist in arr2?



For example I selected 14 from arr1, since it is already existing in arr2, the button will be disabled and should not be pushed in arr3.


More From » angularjs

 Answers
1

That is a JavaScript relating question, not AngularJS. But may that answer your question:



if(arr2.indexOf(14) == -1){
arr3.push(14);
}

[#74172] Tuesday, November 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alli

Total Points: 409
Total Questions: 101
Total Answers: 105

Location: The Bahamas
Member since Tue, Apr 27, 2021
3 Years ago
alli questions
Sat, Apr 23, 22, 00:00, 2 Years ago
Mon, May 18, 20, 00:00, 4 Years ago
Tue, Mar 24, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;