In following program, because of a typo mistake, the test() function returns zero. Actual expected value is different than zero. Assuming the typo mistake is fixed find the expected output and enter the number as answer.

var nums = [100,1000,10,1010];

Code

function test() {

var a = nums[0];

var b = nums[0];

for (i = 0; i < a.length; i++) {

if (nums[i] > a) a = nums[i];

if (nums[i] <= b) b = nums[i];

}

return b - a;

}

Copyright GeekInterview.com

## C program - find mistake

var nums = [100,1000,10,1010];

## Related Answered Questions

## Related Open Questions