T
Tom de Neef
The tutorials are very superficial when it comes to passing variables to
functions and I can not find an answer to this (engineered) example:
function previousElement(element, list, previous)
// should return true if element found in list
// in that case previous should get value of element at lower place in list
{ var k
for (k=1; k<list.length; k++)
{ if list[k] == element { previous = list[k-1]; return true } }
return false
}
In other words: how do you specify that previous should be called by
reference, so that a change within the function is reflected in the value of
previous outside the function. This would be the case when previous is an
object. But in this case it is a string or an integer.
Thank you
Tom
functions and I can not find an answer to this (engineered) example:
function previousElement(element, list, previous)
// should return true if element found in list
// in that case previous should get value of element at lower place in list
{ var k
for (k=1; k<list.length; k++)
{ if list[k] == element { previous = list[k-1]; return true } }
return false
}
In other words: how do you specify that previous should be called by
reference, so that a change within the function is reflected in the value of
previous outside the function. This would be the case when previous is an
object. But in this case it is a string or an integer.
Thank you
Tom