如何将 javascript 中的整个单词大写?
How do you capitalize a whole word in javascript?
谁能告诉我如何将我的全名大写,从 Jason Sims 变成 JASON SIMS!
['Name:', 'Jason Sims'],
['Career: Welder'],
['Description: In transition to becoming a developer!'],
];```
这边
var name = "Whatever";
console.log(name.toUpperCase());
你可以用map
来做:
const data = [
['Name:', 'Jason Sims'],
['Career: Welder'],
['Description: In transition to becoming a developer!'],
];
const altData = data.map(pair => {
return pair[0] === 'Name:' ? [pair[0], pair[1].toUpperCase()] : pair;
});
console.log(altData)
谁能告诉我如何将我的全名大写,从 Jason Sims 变成 JASON SIMS!
['Name:', 'Jason Sims'],
['Career: Welder'],
['Description: In transition to becoming a developer!'],
];```
这边
var name = "Whatever";
console.log(name.toUpperCase());
你可以用map
来做:
const data = [
['Name:', 'Jason Sims'],
['Career: Welder'],
['Description: In transition to becoming a developer!'],
];
const altData = data.map(pair => {
return pair[0] === 'Name:' ? [pair[0], pair[1].toUpperCase()] : pair;
});
console.log(altData)