Answer the question
In order to leave comments, you need to log in
How to properly remove an element from an array?
it is necessary that the last letter from the array is removed on 'c'.
I did everything as on the Internet, then 2 elements then appear. In general, I did not really find anything. Help I'm just learning
let a = document.querySelector('.a'),
b = document.querySelector('.b'),
c = document.querySelector('.c');
let array = [a,b]
let pup = []
for (let element of array) {
element.addEventListener('click', ()=>{
pup.push(element.value)
let input = document.querySelector('.input')
input.value = pup.join('')
c.addEventListener('click', ()=>{
})
})
}
Answer the question
In order to leave comments, you need to log in
const a = document.querySelector('.a'),
b = document.querySelector('.b'),
c = document.querySelector('.c');
const input = document.querySelector('.input')
const array = [a,b,c]
let pup = []
for (let element of array) {
element.addEventListener('click', ({target})=>{
if(['a','b'].includes(target.value)) {
pup.push(target.value)
} else {
pup.pop()
}
input.value = pup.join('')
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question