繁体   English   中英

Ramda将字符串数组大写

[英]Uppercase an array of strings with Ramda

我正在尝试使用Ramda来使点函数变为大写的字符串数组,但是我对此并不陌生 ,并且无法解决

const list = ['a', 'b', 'c', 'd', 'e']
const fn = R.compose(R.toUpper, R.map)
console.log('result', fn(list))

让我Uncaught TypeError: function n(r){return 0===arguments.length||w(r)?n:t.apply(this,arguments)} does not have a method named "toUpperCase"

我也尝试过

const fn = R.compose(R.toUpper, R.map(list))
console.log('result', fn())

但得到同样的错误。

如何使用Ramda做到这一点?

您不需要撰写。 R.map是经过咖喱处理的,因此您只需使用单个参数即可调用它

const fn = R.map(R.toUpper)

演示版

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM