Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Create a Counter Object or Map in javascript

let string = 'kapilalipak';
const table={}; 
for(let char of string) {
  table[char]=table[char]+1 || 1;
}
// Output
{k: 2, a: 3, p: 2, i: 2, l: 2}
Comment

PREVIOUS NEXT
Code Example
Javascript :: multiply js 
Javascript :: create 2d array in javascript filled with 0 
Javascript :: math floor html 
Javascript :: apply() js 
Javascript :: first n elements of array js 
Javascript :: js lambda 
Javascript :: firebase get key value 
Javascript :: usenavigate and uselocation in react 
Javascript :: nodejs class template export 
Javascript :: how to assign onEdit to specigfic tab 
Javascript :: javascript global function 
Javascript :: timeout 30000 milliseconds 
Javascript :: how to navigate to another page with settimeout reactjs 
Javascript :: es6 closures 
Javascript :: vuejs copy to clipboard 
Javascript :: electron iframe require is not defined 
Javascript :: django pointfield json example 
Javascript :: js insert a point each three digit 
Javascript :: loops javascript 
Javascript :: convert string to regular expression js 
Javascript :: array.findindex is not a function 
Javascript :: auth provider react 
Javascript :: avoid compressing imagepicker react native 
Javascript :: delay sleep 
Javascript :: environment texture in three.js 
Javascript :: how to give default value in jquery 
Javascript :: mern heroku Error: ENOENT: no such file or directory 
Javascript :: Event Custom Fire 
Javascript :: player.filter 
Javascript :: override backswipe behaviour in ios and android react native 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =