max char js
function maxChar(str) {
let charCountObj = {};
let maxChar = "";
let maxCount = 0;
// Fill out CharCountObj
// Updates new MaxCount
for (let i = 0; i < str.length; i++) {
const char = str[i];
charCountObj[char] = charCountObj[char] + 1 || 1;
if (charCountObj[char] > maxCount) {
maxChar = char;
maxCount = charCountObj[char];
}
}
return maxChar;
}
Also in JavaScript:
- jquery form serialize object
- get an element from outside of iframe jquery
- p5js unset fill
- Qwiklabs Assessment: Working with Regular Expressions
- iterate over array javascript
- ajax call
- Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x
- firestore update array
- How to check whether a string contains a substring in JavaScript?
- javascript math ceiling function
- window location in react
- reactnode prop-types
- HOW WRITE AND SAVE JSON FILE IN NODEJS
- javascript open new window
- local storage javascript
- javascript update local storage array
- send info with get request in js
- javascript break inner loop
- resolve vs return promise js
- js cookie
- empty path redirection on home page in angular routing
- smooth scroll to top jquery
- How to delete an item in an object in redux
- convert arrow function to normal function javascript online