1

Initially I had,

var value = parseInt(getValue(), 10);

where getValue() returned one value but now it returns multiple values.

I tried this:

var value = [];

    getValue().forEach(function(item) {
       value.push(parseInt(item, 10))
    });

But it returns undefined.

Arrow functions are not supported.

3
  • Maybe we need to see what getValue actually holds since the code looks correct. Commented May 18, 2018 at 16:05
  • I'm not sure what is the problem. Isn't value just holding the array you need after your code ends? Is simply return value what you are missing? Otherwise it seems that the problem lies inside getValue() function. Commented May 18, 2018 at 17:44
  • It is resolved now. This code was for live tests and it was not hitting domain to fetch the values and hence getValue() was not returning anything. Thanks Commented May 18, 2018 at 18:16

1 Answer 1

1

getValue is a function. You have to call the function to get the return value:

let values = getValue().map(e => parseInt(e, 10));

If you have to stick with ES5, try this:

var values = getValue().map(function(item){
    return parseInt(item, 10);
});
Sign up to request clarification or add additional context in comments.

1 Comment

I called the function, there was typo in my post, which I edited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.