function partition(arr, f) {
    return arr.reduce((acc, x) => {
        const [a, b] = acc
        if (f(x)) return [[...a, x], b]
        return [a, [...b, x]]
    }, [[], []])
}

arr = [1,2,3,4,5,6,7]
f = (x) => x % 2 == 1
console.log(partition(arr, f));

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: