Alternate capitalization
JavaScript
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:
- Title
- how to import jquery in js file
- Category
- JavaScript
- Title
- get looping in jquery
- Category
- JavaScript
- Title
- enzyme test method
- Category
- JavaScript
- Title
- how to get value in array object value using for loop in javascript
- Category
- JavaScript
- Title
- how to add element in json object
- Category
- JavaScript
- Title
- axios delete request payload
- Category
- JavaScript
- Title
- command to start api on react
- Category
- JavaScript
- Title
- iso to date javascript
- Category
- JavaScript
- Title
- javascript array column
- Category
- JavaScript
- Title
- fonction fleche javascript
- Category
- JavaScript
- Title
- clear input field javascript
- Category
- JavaScript
- Title
- get last item in array js
- Category
- JavaScript
- Title
- Javascript detect mobile browser
- Category
- JavaScript
- Title
- empty div jquery
- Category
- JavaScript
- Title
- adding delay in javascript foreach loop
- Category
- JavaScript
- Title
- deny ready jquery
- Category
- JavaScript
- Title
- How to pass variables from js to html node
- Category
- JavaScript
- Title
- array find method javascript
- Category
- JavaScript
- Title
- binary search in js
- Category
- JavaScript
- Title
- input in javascript
- Category
- JavaScript
- Title
- javascript and
- Category
- JavaScript
- Title
- download image in nodejs
- Category
- JavaScript
- Title
- get current screen name react navigation
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- how to use chart js in vue js
- Category
- JavaScript
- Title
- how to generate random string in javascript
- Category
- JavaScript
- Title
- how to append object in array javascript
- Category
- JavaScript
- Title
- emit resize event in angular
- Category
- JavaScript
- Title
- javascript check if string contains substring
- Category
- JavaScript
- Title
- how to make a div scrollable
- Category
- JavaScript
- Title
- check array for duplicate values javascript
- Category
- JavaScript
- Title
- create table jquery
- Category
- JavaScript
- Title
- how accurate is pi javascript
- Category
- JavaScript
- Title
- es6 closures
- Category
- JavaScript
- Title
- Cannot set property 'innerHTML' of null
- Category
- JavaScript
- Title
- clone an object javascript
- Category
- JavaScript
- Title
- how to import npm packages in node.js?
- Category
- JavaScript
- Title
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project electronicbookshop: Compilation failure
- Category
- JavaScript
- Title
- how to do bubble sort in javascript
- Category
- JavaScript
- Title
- get browser timezone javascript
- Category
- JavaScript
- Title
- command to create react app
- Category
- JavaScript
- Title
- .classList
- Category
- JavaScript
- Title
- get today's date javascript
- Category
- JavaScript
- Title
- how to check if something is array javascript
- Category
- JavaScript
- Title
- compare dates in javascript
- Category
- JavaScript
- Title
- javascript after split then trim whitespace
- Category
- JavaScript
- Title
- dotenv
- Category
- JavaScript
- Title
- A cookie associated with a cross-site resource at http://placeholder.com/ was set without the `SameSite` attribute.
- Category
- JavaScript
- Title
- how to set three js canvas width 100%
- Category
- JavaScript
- Title
- implementing node js app on server and runing npm
- Category
- JavaScript
- Title
- javascript click event notifications
- Category
- JavaScript
- Title
- how to print two arrays together
- Category
- JavaScript
- Title
- defining props in react
- Category
- JavaScript
- Title
- check row empty array javascript
- Category
- JavaScript
- Title
- check to see if number is a decimal javascript
- Category
- JavaScript
- Title
- check first two number jquery
- Category
- JavaScript
- Title
- discord.js start code
- Category
- JavaScript
- Title
- class component react
- Category
- JavaScript
- Title
- get all keys in json object
- Category
- JavaScript
- Title
- javascript Arranging Coins
- Category
- JavaScript
- Title
- Find parent and child from array javascript
- Category
- JavaScript
- Title
- async iife
- Category
- JavaScript
- Title
- javascript check if elements of one array are in another
- Category
- JavaScript
- Title
- how to check if object is undefined in javascript
- Category
- JavaScript
- Title
- command to create custom pipe in angular 6
- Category
- JavaScript
- Title
- for in loops javascript
- Category
- JavaScript
- Title
- axios js and react
- Category
- JavaScript
- Title
- injected stylesheet remove
- Category
- JavaScript
- Title
- access angular app outside localhost
- Category
- JavaScript
- Title
- get all the child of the same class javascript
- Category
- JavaScript
- Title
- how to make a javascript game
- Category
- JavaScript
- Title
- javascript change url hash
- Category
- JavaScript
- Title
- how to read json file with gluegun
- Category
- JavaScript
- Title
- javascript class
- Category
- JavaScript
- Title
- api platform vue generator
- Category
- JavaScript
- Title
- how to check if item is in list js
- Category
- JavaScript
- Title
- check angular version
- Category
- JavaScript
- Title
- how to display an image on text click using jQuery
- Category
- JavaScript
- Title
- find particular object from array in js
- Category
- JavaScript
- Title
- display json data in reactjs
- Category
- JavaScript
- Title
- event listener in react
- Category
- JavaScript
- Title
- Discord embeds
- Category
- JavaScript
- Title
- javascript base64 encode string
- Category
- JavaScript
- Title
- bind jquery trough name
- Category
- JavaScript
- Title
- if statement in ejs
- Category
- JavaScript
- Title
- angular for loop
- Category
- JavaScript
- Title
- how to get session javascript ws3schools
- Category
- JavaScript
- Title
- angular reactive forms
- Category
- JavaScript
- Title
- how to change port in next js
- Category
- JavaScript
- Title
- convert json to 2d array
- Category
- JavaScript
- Title
- collapse in angular 4
- Category
- JavaScript
- Title
- create react app theme_color
- Category
- JavaScript
- Title
- how to capitalize a letter based on an index in javascript
- Category
- JavaScript
- Title
- javascript array pop
- Category
- JavaScript
- Title
- how to create response time router node js
- Category
- JavaScript
- Title
- javascript call php function with parameters
- Category
- JavaScript
- Title
- check if string contains character javascript
- Category
- JavaScript
- Title
- javascript class inheritance
- Category
- JavaScript
- Title
- check object in array javascript
- Category
- JavaScript
- Title
- clear input field value javascript
- Category
- JavaScript