JSFiddle - React, Tailwind, and code Playground

by jrunning

JavaScript

function fn(except, digits = 5) {
  return Array.from({ length: 5 }, () => {
    let n;
    while (n = Math.floor(Math.random() * 10), except.includes(n));
    return n;
  }).join('');
}

console.log(fn([6,3,8]));