problem showing Variables undefined not showing

Related searches

1.My Code is getting all the prices and output it on the DOM,compute it by getting the subtotal of textprice,calcprice,backprice, and Get it out from the global scope.

2.It has sales tax of 13%

3.The code should Use getelementbyID and textContent.

4.Keep all the variables from global scope

5.My Problem is the textPrice is undefined?

   //Variables
   function getInput(){
       let items = ['textPrice', 'calcPrice', 'backPrice'] ;
       return items;
   }


   function getBackPrice(){
       let backElement = document.getElementById("back-price") ;
       let backPrice= document.getElementById("back-price").textContent;
       return backPrice;
   }


   function getCalcPrice(){
       let calcElement = document.getElementById("calc-price") ;
       let calcPrice= document.getElementById("calc-price").textContent;
       return calcPrice;
   }

   function getTextPrice(){
       let textElement = document.getElementById("text-price") ;
       let textPrice= document.getElementById("text-price").textContent;
       return textPrice;
   }

   //Get Subtotal
   function getsubTotal(){
       let subTotal = parseFloat(textPrice) + parseFloat(calcPrice) + parseFloat(backPrice);
       return subTotal;

   }

   getsubTotal(); ```

function getInput(){
       let items = ['textPrice', 'calcPrice', 'backPrice'] ;
       return items;
   }


   function getBackPrice(){
       let backElement = document.getElementById("back-price") ;
       let backPrice= document.getElementById("back-price").textContent;
       return backPrice;
   }


   function getCalcPrice(){
       let calcElement = document.getElementById("calc-price") ;
       let calcPrice= document.getElementById("calc-price").textContent;
       return calcPrice;
   }

   function getTextPrice(){
       let textElement = document.getElementById("text-price") ;
       let textPrice= document.getElementById("text-price").textContent;
       return textPrice;
   }

   //Get Subtotal
   function getsubTotal(){
      var textPrice= $("#text-price").text();
      var calcPrice= $("#calc-price").text();
      var backPrice= $("#back-price").text();

      let subTotal = parseFloat(textPrice) + parseFloat(calcPrice) + parseFloat(backPrice);
      $("#sub-total").text(subTotal.toFixed(2));
      return subTotal;
   }

   getsubTotal();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="">
            <h2>Purchased Items</h2>
            <table>
              <thead>
                <tr>
                    <th scope="col">Item Name</th>
                    <th class="quantity" scope="col">Item Price</th>
                    <th class="price" scope="col">Quantity</th>
                    <th></th>
                </tr>
              </thead>
              <tbody>
                  <tr><td>Backpack</td><td class="quantity">1</td><td id="back-price" class="price">56.99</td><td></td></tr>
                  <tr><td>Calculator</td><td class="quantity">1</td><td id="calc-price" class="price">104.89</td><td></td></tr>
                  <tr><td>Textbook</td><td class="quantity">1</td><td id="text-price" class="price">51.97</td><td></td></tr>
              </tbody>
              <tfoot>
                  <tr><td></td><td></td><td id="sub-total" class="price"><td class="">Subtotal</td></tr>
                  <tr><td></td><td></td><td id="tax-amount" class="price"></td><td class="">Tax</td></tr>
                  <tr><td></td><td></td><td id="total" class="price total"></td><td class="total">Total Cost</td></tr>
             </tfoot>
            </table>
        </section>

7 Tips to Handle undefined in JavaScript, Undefined value primitive value is used when a variable has not been assigned a value. var declaration problem is the variable hoisting within the function scope. When working with arrays, to avoid undefined , be sure to use valid array� Note: There are many more variables and arrays declared in the module which I am not showing. During debug while I am in PROGRAM MAINDRV: 1. The allocatable array GOPRINT shows up as an Undefined pointer/array. 2. All of the integer parameters NCOMP, NPTS, NFAC, NRESTOP, CASENUM show up as Undefined variables. 3.

//Gets the Prices of Items
function getBackPrice(){
    let backElement = document.getElementById("back-price") ;
    let backPrice= document.getElementById("back-price").textContent;
    return backPrice;
}


function getCalcPrice(){
    let calcElement = document.getElementById("calc-price") ;
    let calcPrice= document.getElementById("calc-price").textContent;
    return calcPrice;
}

function getTextPrice(){
    let textElement = document.getElementById("text-price") ;
    let textPrice= document.getElementById("text-price").textContent;
    return textPrice;
}


//Gets Subtotal
function getsubTotal(){
    //let subTotal = parseFloat(textPrice) + parseFloat(calcPrice) + parseFloat(backPrice);
    let subTotal = Number(getTextPrice()) + Number(getCalcPrice()) + Number(getBackPrice());
    let subTotalElement = document.getElementById("sub-total");
    subTotalElement.textContent = (subTotal);

    return subTotal;

}

//Calculate SalesTax
function calcsalesTax(subTotal) {
    const taxAmount = 0.13;
    //let salestaxElement = document.getElementById("tax-amount");
    //let salesTax = document.getElementById("tax-amount").textContent;
    //salesTax = getsubTotal() * Number(taxAmount);
    //return salesTax;

    let salesTax = getsubTotal() * Number(taxAmount);
    let salestaxElement = document.getElementById("tax-amount");
    salestaxElement.textContent = (salesTax);
    return salesTax;
}



//calculate final total cost
function calcfinalTotalCost() {
   let finalTotalCost = getsubTotal() + calcsalesTax();
   let calcfinalTotalCostElement = document.getElementById("total");
   calcfinalTotalCostElement.textContent = (finalTotalCost);

   return finalTotalCost;
}


function Output(){
    const salesTax = calcsalesTax();

    console.log('Item Subtotal = ',getsubTotal());
    console.log('Sales Tax = ',calcsalesTax());
    console.log('Total Cost = ',calcfinalTotalCost());
}

Output();

Linting not showing 'undefined-variable' error with 'generated , Linting not showing 'undefined-variable' error with 'generated-members' pylint args #11778. Open. fabmazz opened this issue on May 13 � 11 comments. Open � VS2019 community - debugging not showing variable values on hover when VS2019 MAC community (released and release candidate)- debugging not showing variable values on hover when paused visual studio for mac macos 10.14 debugger

You did wrong in the below function

function getsubTotal(){
       let subTotal = parseFloat(textPrice) + parseFloat(calcPrice) + parseFloat(backPrice);
       return subTotal;

   }

just you should call the function instead of using the variable, because textPrice, calcPrice, backPrice these variables currently in local scope.

simply you can modify like this:

function getsubTotal(){
           let subTotal = parseFloat(getTextPrice()) + parseFloat(getCalcPrice()) + parseFloat(getBackPricea());
           return subTotal;

       }

undefined, A variable that has not been assigned a value is of type undefined . use typeof is that it does not throw an error if the variable has not been declared. so knowing if a variable is declared can be read by seeing whether it is� If a variables column is hidden in the worksheet, then the variables list might not display your variable. To determine whether any columns are hidden, with the worksheet active, choose Editor > Column Properties > Hide/Unhide Columns. To display hidden variables columns in dialog boxes, with the worksheet active, select Editor > Column Properties > Use Hidden Columns in Dialog Boxes.

How to Determine If Variable is Undefined or NULL in JavaScript, In JavaScript if a variable has been declared, but has not been assigned a Therefore, if you try to display the value of such variable, the word "undefined" will be and thus fixing it would create a lot more problem, so idea of fixing this issue� VS2017 15.7.0 Community debugger not showing variable values on hover fixed in: visual studio 2017 version 15.7.5 windows 10.0 visual studio 2017 version 15.7 debugger Nemanja Stankovic reported May 07, 2018 at 07:49 PM

Null and Undefined, A variable or an object has an undefined value when no value is assigned null and undefined is one of the main reasons to produce a runtime error in the� Undeclared: It occurs when we try to access any variable that is not initialized or declared earlier using var or const keyword. If we use ‘typeof’ operator to get the value of an undeclared variable, we will face the runtime error with return value as “undefined”. The scope of the undeclared variables is always global.

You can use the Boolean equal sign (ctrl 😃 so the undefined variables won't be in red. Is that what you want?

Comments
  • could you please share your html part as well?
  • what i did is i called the function name, instead of the variable name. -case closed