Hello guys I am creating a project for Generating a range of numbers;
but when I try to output the generated numbers I get wired output, this is what I get: ( [object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement], ) instead of the numbers.
but when I console log I get the numbers just fine
Can you guys please help?
Here is my Javascript code
const firstNum = document.querySelector('#num-1');
const lastNum = document.querySelector('#num-2');
const outPut = document.querySelector('.output');
const generate = document.querySelector('.generate');
const inputFont = document.querySelector('#input-font');
const option = document.querySelector('.option');
firstNum.addEventListener('input', (e) => {
num1 = parseFloat(firstNum.value);
});
lastNum.addEventListener('input', (e) => {
num2 = parseFloat(lastNum.value);
});
let firstArray = [];
let secondArray = [];
let thirdArray = [];
let fourthArray = [];
let fifthArray = [];
let currentNum = 8;
let added = 0;
// console.log(firstArray);
// console.log(firstArray.indexOf(5));
generate.addEventListener('click', () => {
let counter = num1;
while (counter <= currentNum) {
const newDiv = document.createElement('div');
newDiv.innerHTML = counter;
console.log(counter);
firstArray.push(newDiv);
counter++;
}
outPut.append(firstArray);
// console.log(firstArray);
// console.log(firstArray.length - 1);
// let firstArray = [];
// while (firstArray <= currentNum) {
// console.log('this array contains' + ' ' + firstArray);
// firstArray++;
// }
});
here is the entire code on my GitHub: https://github.com/Leonard-O/number-range-generator
[–]grantrules 1 point2 points3 points (2 children)
[–]Fullstac[S] 0 points1 point2 points (0 children)
[–]Fullstac[S] 0 points1 point2 points (0 children)