0
\$\begingroup\$
export const updateWatchlist = (coin: IAsset, watchlist: IAsset[]) => {
  watchlist.push(coin)
  return watchlist.map((c) => c)
}

Is this 1-line-able with a lib like Ramda?

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

You could just write

export const updateWatchlist = (coin: IAsset, list: IAsset[]) => [...list, coin];
\$\endgroup\$
-2
\$\begingroup\$

Figured it out :D

https://ramdajs.com/docs/#concat

export const updateWatchlist = (coin: IAsset, watchlist: IAsset[]) => R.concat(watchlist, [coin]);
\$\endgroup\$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.