AUTOR PREGUNTA #1
Publicado 01 junio 2014 - 18:40
¿Cómo puedo sumar propiedades de un objeto de tipo JSON en coffescript? Mi objeto luce de la siguiente manera:
object = title : 'objeto' properties : attribute1 : random_number: 4 attribute_values: a: 16 b: 'sin result' attribute2 : random_number: 8 attribute_values: a: 11 b: 'sin result' some_random_stuff: 'aleatorio'
-
2 personas más tuvieron esta duda Yo también
PREGUNTAS SIMILARES
#3
Publicado 01 junio 2014 - 21:38
Puedes tratar con algo más funcional incluyendo Underscore.js, te dejo como sería:
sum = (arr) -> _.reduce arr, ((memo, num) -> memo + num), 0 sum _.pluck(object.properties, 'a')
AUTOR PREGUNTA #4
Publicado 02 junio 2014 - 02:00
Gracias a ambos
