Guest User

Untitled

a guest
Jan 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. let a_list = [
  2. {
  3. desc: 'Hello World'
  4. },
  5. {
  6. desc: 'Second Item'
  7. },
  8. {
  9. desc: 'third'
  10. }
  11. ]
  12.  
  13. let total_count = 0
  14.  
  15. calcArrayStringLengths(array, property, set_value) {
  16. let counts = []
  17. array.forEach(i => {
  18. counts.push(i[property].length)
  19. })
  20. this[set_value] = counts.reduce((accumulator, currentValue) => accumulator + currentValue) // for VueJs
  21. //or
  22. total_count = counts.reduce((accumulator, currentValue) => accumulator + currentValue) // for VueJs
  23. }
  24.  
  25. calcArrayStringLengths(a_list, desc, total_count)
Add Comment
Please, Sign In to add comment