Loop through the elements, use textContent, and output that

I need to Initialize the elements at the beginning of your function, then use them down in the output section of the function: function processPurchase().

Did I initialize these elements correctly?
How I should use them for output?

//read the textContent of the element on a different line than the line that used to read the element
function getTextById(id) {
let element = document.getElementById(id) ;
let text = 0;
if ( element ) {
text = element.textContent ;
}
return text ;
}

//final total with Tax and output results;
function processPurchase(){
let sutotalContent = getTextById(“sub-total”);
let taxContent = getTextById(“tax-amount”);
let totalContent = getTextById(“total”);

let subtotal = 0 ;
let salestax = 0 ;
let total = 0 ;

let subtotalElement = 0;
let taxElement = 0;
let totalElement = 0;

subtotalElement = document.getElementById("sub-total");
taxElement = document.getElementById("tax-amount");
totalElement = document.getElementById("total");

subtotal = dataCalculeting();
salestax = subtotal * salesTaxRate();
total = subtotal + salestax ;

subtotalElement.textContent = currencyUS(subtotal);
taxElement.textContent = currencyUS(salestax);
totalElement.textContent = currencyUS(total);

}