Create an array of size 10 and initialize all elements as false . This array is used to check if a digit is already seen or not .
var arr = Array ( 10 ) . fill ( 0 ) ; for ( var i = 0 ; i < 10 ; i ++ ) arr [ i ] = false ;