Home>
https://codepen.io/Tester2004-07/pen/MWwvoja
let d15= [0, 2, 5, -4, 6, 22, -9, -12, 8, 12, 13, 78];
function f15() {
let inp= +document.querySelector('.i-15').value;
if( d15.indexOf(inp != -1) ) {
console log(1);
}
else {
d15.push(inp);
}
}
document.querySelector('.b-15').onclick= f15;
-
Answer # 1
let d15= [0, 2, 5, -4, 6, 22, -9, -12, 8, 12, 13, 78]; function f15() { let inp= +document.querySelector('.i-15').value; if (d15.indexOf(inp)== -1) { d15.push(inp); } showArr('.out-15', d15); } document.querySelector('.b-15').onclick= f15;
As it stands, your answer is not clear. Please click edit below the post to add more details to help others understand how he answers the question asked. You can find more information on how to write good answers in the Help.
Дух сообщества2022-02-12 00:22:07 -
Answer # 2
let d15= [0, 2, 5, -4, 6, 22, -9, -12, 8, 12, 13, 78]; function f15() { let inp= document.querySelector('.i-15').value; if(d15.indexOf(+inp) != -1){ console. log('There is an element in the array'); } else{ d15.push(+inp); console log(d15); } } document.querySelector('.b-15').onclick= f15;
<input class="i-15"><button class="b-15">Tyk</button>
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
The parenthesis is not there in the condition. Well, in general, it's easier to use includes instead of indexOf.
Yaant2022-02-12 11:59:37