appendAll
appendAll
(appended: array) => (base: array) => array
Append one array to another
const append34 = appendAll([3, 4]) append34([1, 2]) // is [1, 2, 3, 4] const append3AndArray4 = appendAll([3, [4]]) append3AndArray4([1, 2]) // is [1, 2, 3, [4]]
const append34 = appendAll([3, 4]) append34([1, 2]) // is [1, 2, 3, 4] const append3AndArray4 = appendAll([3, [4]]) append3AndArray4([1, 2]) // is [1, 2, 3, [4]]
const append34 = appendAll([3, 4]) append34([1, 2]) // is [1, 2, 3, 4] const append3AndArray4 = appendAll([3, [4]]) append3AndArray4([1, 2]) // is [1, 2, 3, [4]]
const append34 = appendAll([3, 4]) append34([1, 2]) // is [1, 2, 3, 4] const append3AndArray4 = appendAll([3, [4]]) append3AndArray4([1, 2]) // is [1, 2, 3, [4]]
This is useful when we want to concatenate two arrays. Below, we create a list of all students by appending new students to the existing list.
const newStudents = ['matt', 'jason'] const appendNewStudents = appendAll(newStudents) const existingStudents = ['amy', 'kim'] const allStudents = appendNewStudents(existingStudents) console.log(allStudents) // is ['amy', 'kim', 'matt', 'jason']
const newStudents = ['matt', 'jason'] const appendNewStudents = appendAll(newStudents) const existingStudents = ['amy', 'kim'] const allStudents = appendNewStudents(existingStudents) console.log(allStudents) // is ['amy', 'kim', 'matt', 'jason']
const newStudents = ['matt', 'jason'] const appendNewStudents = appendAll(newStudents) const existingStudents = ['amy', 'kim'] const allStudents = appendNewStudents( existingStudents ) console.log(allStudents) // is ['amy', 'kim', 'matt', 'jason']
const newStudents = ['matt', 'jason'] const appendNewStudents = appendAll(newStudents) const existingStudents = ['amy', 'kim'] const allStudents = appendNewStudents( existingStudents ) console.log(allStudents) // is ['amy', 'kim', 'matt', 'jason']