function times2(blobst){
var newArray = [];
for(i = 0; i <blobst.length; i++){
newArray.push(blobst[i] * 2);
}
return newArray;
}
set('test', times2([1,2,3,4,5]))
{test}
why it doesn't work?
Hi,
and thank you for the interest.
Yes, it's inside a section and indented (all java activated, function is blue, blobst yellow, etc).
It works fine out of Squiffy, showing the result: "2,4,6,8,10".
This works for me:
Try this out: [[test section]]
[[test section]]:
function times2(blobst){
var newArray = [];
for(i = 0; i <blobst.length; i++){
newArray.push(blobst[i] * 2);
}
return newArray;
};
set('test', times2([1,2,3,4,5]));
{test}
OUTPUT
Try this out: test section
2,4,6,8,10
PS
If I were you, I'd put that function in a master section. Then, You can call the function any time in the code:
Try this out: [[test section]]
[[test section]]:
set('test', times2([1,2,3,4,5]));
{test}
[[]]:
times2 = function(blobst){
var newArray = [];
for(i = 0; i <blobst.length; i++){
newArray.push(blobst[i] * 2);
}
return newArray;
};
Thank you, it works!
(declaring "i "):
[[test section]]:
var i;
function times2(blobst){
var newArray = [];
for(i = 0; i <blobst.length; i++){
newArray.push(blobst[i] * 2);
}
return newArray;
};
set('test', times2([1,2,3,4,5]));
{test}