Developer Intermediate > Lightning Components > Using JavaScript Controllers With Components

The error that Trailhead is giving me is that "Challenge Not yet complete... here's what's wrong: The client side controller does not set a value for the outputNumber component".... BUT based on when I plug this into an app and run it, it sure appears that the value for outputNumber is being set.

What am I doing wrong? Any help is appreciated.

Here is the Component:

<aura:component >
    <aura:attribute name="total" type="Integer" default="0"/>
    <ui:inputNumber aura:id="inputOne" label="Enter 1"/>
    <ui:inputNumber aura:id="inputTwo" label="Enter 2"/>
    <ui:inputNumber aura:id="inputThree" label="Enter 3"/>
    <ui:button label="Submit" press="{!c.calculate}"/>
    <ui:outputNumber aura:id="totalValue" value="{!v.total}"/>

and here is the controller:

    calculate : function(component, event, helper) {
        var inputOne = parseInt(component.find("inputOne").get("v.value"));

        var inputTwo = parseInt(component.find("inputTwo").get("v.value"));
        var inputThree = parseInt(component.find("inputThree").get("v.value"));
        var total = inputOne + inputTwo - inputThree;
        if (isNaN(total)){
            component.set("v.errors", [{message:"Total not a number: " + total}]);
        } else {
            component.set("v.total", total);
  • 1
    Trailhead developer forum may be right place for this to quickly get attention from Trailhead team .I will remove if and else since error handling is not asked in challenge and check challenge .Thanks – Mohith Shrivastava Apr 14 '16 at 16:47
  • I tried there... nobody responded and I just am so stuck on this one, it is frustrating me. – notthehoff Apr 14 '16 at 18:57
  • 1
    Can you post the question link here and we tweet Trailhead team to get some help – Mohith Shrivastava Apr 14 '16 at 18:59
  • 1
    Are you on twitter ? I just pinged Trailhead Team to help us with this .Thanks – Mohith Shrivastava Apr 14 '16 at 19:14
  • 1
    You da real MVP. @notthehoff – notthehoff Apr 14 '16 at 19:25

Cross Posting the answer from Dev forum

In your component, try changing your totalValue provider to:

<ui:outputNumber aura:id="totalValue" value="" />

And also in your Js controller use the below


But your original solution is correct no doubt .This is because Trailhead challenge looks for specific things .Also note Find via Aura Id is one of the best practices when accessing element .

| improve this answer | |

Here's a hint. Take a look at your definition for ui:outputNumber in your component. What are you "outputting"? Now look at your controller and think about what you're passing back to it. We have a rule here in this forum that we don't provide solutions to Trailhead questions. However, this should point you in the right direction.

| improve this answer | |
  • > What am I outputting? v.total... it appears on the screen. What is the controller passing back to the screen? it is setting v.total to be total. I am confused on what is wrong, as it actually is outputting the thing it is specifically asking for, but just ...apparently... not in the way they want? – notthehoff Apr 14 '16 at 18:54
  • @notthehoff Your code looks correct to me but may not be same as that of whats expected .So lets get this sorted with Trailhead team – Mohith Shrivastava Apr 14 '16 at 18:59
  • As a side note, I did remove the if/else, as your comment did make sense.... didn't help – notthehoff Apr 14 '16 at 19:00
  • That was a step in the right direction, but think in terms of "returning" what you were "getting". What's the name of that "v." variable? – crmprogdev Apr 14 '16 at 19:21
  • Technically, I am not returning anything... I am setting v.total to total and then ui:outputNumber is dynamically changing to what the total attribute is set to. – notthehoff Apr 14 '16 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.