I changed the unconditional return statement to a conditional return statement but it still does not work
No you didn't. return c; is still unconditional and inside the loop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
function delta(a)
{
var c = new Array(); //creates an array with 1 element. element is undefined
var i;
for( i = 0; i < a.length; i++) // a could be an array, but as passed in line 17, is an integer. This will not work
{
if(c[i]+=a) // c[i]+=a does not evaluate to a boolean expression. Will never be true. Also, each member of c that is added will be of type NaN (not a number)
{
break; // will never execute
}
return c; // return statement still inside for-loop, still unconditional. Function returns on first iteration of loop
}
document.write(c); // will never execute
}
var hunter = delta(6621); //given line 7, should be an array. is integer. Conversely, line 7 could be rewritten as: for(i=0; i < a; i++);
Also, go here http://ideone.com/. In the language menu select Javascript. It probably will not make any difference whether you use Javascript Rhino or Javascript Spidermonkey.
I see that my last post was reported . Was it against the rules ? I was only asking some questions to get help nothing more nothing less . So I do not understand why it was reported !!! therefore , I would like to know why my last post was reported . What was wrong with my last post?
Well. We've told you multiple times that you should find a Javascript forum. While some of us don't mind fielding questions for other languages, this is still a C++ forum.