var d = [ { id:"2", num:"2", c:20 }, { id:"4", num:"4", c:50 }, { id:"3", num:"4", c:70 } ] var fs = require("fs-extra"); var path = __dirname+"/d.json"; var d3 = JSON.parse(fs.readFileSync(path,"utf-8")); //var d2 = require("./d.json"); //console.log(d2) var s = 4; async function check() { for (let i of d3) { if (i.num == s) { var f = d3.find(item => item.num == s); //console.log(f) console.log("đã thưởng",i.c*2,"$") } } //const d4 = d3; d3 = d3.filter(ie => ie.num != s); console.log(d3) fs.writeFileSync(path,JSON.stringify(d3,null,4),"utf8") } console.log(" số của bạn là 139392\n kết quả sổ xố hôm nay là 392293\n bạn trúng",countd(139392,392293),"số\n mỗi số giá 20k => 20*6 = 120k, bạn lỗ :)") //console.log(d3.filter(ie => ie.num !== s)) //d3 = d3.filter(ie => ie.num !== s) //setInterval(check,4000)j function countd(N,M) { // Stores the count of common digits var count = 0; // Stores the count of digits of N var freq1 = Array(10).fill(0); // Stores the count of digits of M var freq2 = Array(10).fill(0); // Iterate over the digits of N while (N > 0) { // Increment the count of // last digit of N freq1[N % 10]++; // Update N N = Math.floor(N / 10); } // Iterate over the digits of M while (M > 0) { freq2[M % 10]++; M = Math.floor(M / 10); } var i; for (i = 0; i < 10; i++) { // If freq1[i] and freq2[i] both excds 0 if (freq1[i] > 0 & freq2[i] > 0) { count++; } } return count; }