Basically, I want to get the textContent of an element which is a number, and another one from another element. Then sum them and store it as innertext of another element and display it to the browser, everytime I do so, the NaN appears instead of the number. (searched for many hours and didnt manage to find a solution)
let price = document.getElementById("productPrice").textContent;
let stack = document.getElementById("cartCounter").textContent;
let num = parseInt(price);
let num2 = parseInt(stack);
let sum = num * num2;
alert(sum); //returns NaN
document.getElementById("finalPrice").innerText = num;
<div id="cartBox">
<h5>Cart</h5>
<hr>
<img src="images/image-product-1.jpg" alt="#" id="test">
<span id="priceBox">
<p>Fall Limited Edition Sneakers</p>
<span id="priceProduct">$125.00</span><span id="x">x</span><span id="productStack">3</span><span
id="finalPrice"></span>
</span>
<span id="productPrice">$125.00</span><span id="discount">50%</span>
<span id="productRealPrice"><del>$250.00</del></span>
<i class='bx bx-cart-alt' onclick="seeCart()"><span id="cartCounter">0</span></i>
I thought using Number() or parseInt() will solve my problem, but didn't.