capitalize
function capitalize1(str) {
const arrOfWords = str.split(" ");
const arrOfWordsCased = [];
for (let i = 0; i < arrOfWords.length; i++) {
const word = arrOfWords[i];
arrOfWordsCased.push(word[0].toUpperCase() + word.slice(1).toLowerCase());
}
return arrOfWordsCased.join(" ");
}const capitalize = s => {
s = s.split('')
let finalArr = []
let i = 0
while(i < 2){
let str = ''
s.forEach((letter, index) => {
if(i % 2 === 0 && index % 2 === 0) str += letter.toUpperCase()
else if(i % 2 !== 0 && index % 2 !== 0) str += letter.toUpperCase()
else str += letter
})
finalArr.push(str)
i++
}
return finalArr
};
console.log(capitalize("abcdef"))
Also in JavaScript:
- synchronous vs asynchronous functions javascript
- memoization javascript
- span change jquery
- how to set time with jwt token in node js
- remove axis tick ends d3
- What is the correct JavaScript syntax for opening a new window called "w2" ?
- for each python json
- how to check if map is map javascript
- javascript sort by id
- multiplication of complex numbers javascript
- react create array
- how to create a server in node js
- javascript includes
- Uncaught (in promise) SyntaxError: Unexpected token O in JSON at position 0
- detect a click outside an element javascript
- pyspark json multiline
- javascript get cpu cores
- javascript leave page warning
- javascript create svg
- disable js in chrome dev tools
- make object move towards player p5js
- react chunk file too large
- set a variable in express.js
- c# print object to json