H
H
holfizz2022-04-20 08:13:12
JavaScript
holfizz, 2022-04-20 08:13:12

How to get text from an array?

I don’t even know how to describe it)) in general, there is a code for example:

let name = document.querySelector('.name'),
    age =  document.querySelector('.age'),
    todo = document.querySelector('.todo'),
    button = document.querySelector('.button');
let array = [name, age,todo]
button.addEventListener('click',()=>{
    console.log()//сюда нужно вывести весь массив только ее текстовую часть
})

it is necessary that all the text from the inputs be displayed in the console, but not separately !!! and in a line separated by commas, how to do it
I don’t know if you understood or not, but please help :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MrColdCoffee, 2022-04-20
@holfizz

console.log(array .join(','));
only if you need a value, then you need to pull out value for example:let name = document.querySelector('.name').value;

W
wonderingpeanut, 2022-04-20
@wonderingpeanut

Let 's go here and read.

The value attribute is a DOMString that contains the current value of the text entered into the text field. You can retrieve this using the HTMLInputElement value property in JavaScript.
let theText = myTextInput.value;

Yep, what you need.
How to concatenate an array of strings is in the answer above

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question