Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let a_list = [
- {
- desc: 'Hello World'
- },
- {
- desc: 'Second Item'
- },
- {
- desc: 'third'
- }
- ]
- let total_count = 0
- calcArrayStringLengths(array, property, set_value) {
- let counts = []
- array.forEach(i => {
- counts.push(i[property].length)
- })
- this[set_value] = counts.reduce((accumulator, currentValue) => accumulator + currentValue) // for VueJs
- //or
- total_count = counts.reduce((accumulator, currentValue) => accumulator + currentValue) // for VueJs
- }
- calcArrayStringLengths(a_list, desc, total_count)
Add Comment
Please, Sign In to add comment