hi, i'm happy to play now with short code and modularize them together.
What saves time and readability !
But in this case i don't see what it's possible to do with the function foreach.
Is it possible to use foreach like this config with a trick in the hide_weapon_internal ?
//normal function who works
if(dalle_moving[0]){
for (var j = 0; j < dalle_moving.length; j++){
dalle_moving[j].hide()
}
}
////////////////////////////////////////////////////////////////////////////////////
//NOW WITH FUNCTIONAL PROGRAMATION
function is_exist(obj){
if(typeof obj != "undefined"){
return true;
}else{
return false;
}
}
function foreach(table,action){
for(var i=0;i<table.length;i++){
action(table[i]);
}
}
//////////////////////////////////////////
var hide_enemy=function(obj){
is_exist(obj[0]) && foreach(obj,obj.hide)
}
hide_enemy(dalle_moving)
//////////////////////////////////////////
//obj.hide don't works because i must say action(obj[i].hide())
//is there a trick to do that with the function foreach as she is ?
i have the feeling that 's possible ....no?