How to use checkDuplicates method in Puppeteer

Best JavaScript code snippet using puppeteer

script.js

Source:script.js Github

copy

Full Screen

...9var recordplayer=0;10var vacuumcleaner=0;11var floorlamp=0;12//Проверяет соединен ли А с Б13function checkDuplicates(L, R) {14 for (var i = 0; i < joins.length; i++) {15 if (joins[i].L == L && joins[i].R == R) {16 return true;17 }18 }19 return false;20}21function isSocket2728busy() {22 if((checkDuplicates(23,28)23 && checkDuplicates(24, 27))24 || (checkDuplicates(12, 27)25 && checkDuplicates(11, 28))) {26 return true;27 }return false;28}29function isSocket1314busy() {30 console.log("http://localhost:63342/GAME.Project/index.html");31 if((checkDuplicates(11,14)32 && checkDuplicates(12,13))33 || checkDuplicates(13, 24)34 || checkDuplicates(14, 23)) {35 console.log("1314busy");36 return true;37 }else {38 console.log("not busy 1314");39 }40 return false;41}42// Функция которая проверяет занят ли разъем(ы)43// больше 1 одинакова номера44// 3(4), 4(4), 11(2), 12(2), 13(2), 14(2),45// 17(5), 18(5), 23(2), 24(2), 27(2), 28(2), 31(2), 32(2), 33(2), 34(2),46// 37(5), 38(5), 47(2), 48(2), 49(3), 50(3), 51(2), 52(2), 57(2),47// 58(2), 63(2), 64(2), 67(3), 68(3), 69(2), 70(2),48function isJoinBusy(socket){49 let number = 0;50 for (let i = 0; i < joins.length; i++) {51 if (joins[i].L == socket) number++;52 if (joins[i].R == socket) number++;53 }54 if (socket == 1 && number < 1) return false;55 if (socket == 2 && number < 1) return false;56 if (socket == 3 && number < 4) return false;57 if (socket == 4 && number < 4) return false;58 if (socket == 5 && number < 1) return false;59 if (socket == 6 && number < 1) return false;60 if (socket == 7 && number < 1) return false;61 if (socket == 8 && number < 1) return false;62 if (socket == 9 && number < 1) return false;63 if (socket == 10 && number < 1) return false;64 if (socket == 11 && number < 2) return false;65 if (socket == 12 && number < 2) return false;66 if (socket == 13 && number < 2) return false;67 if (socket == 14 && number < 2) return false;68 if (socket == 15 && number < 1) return false;69 if (socket == 16 && number < 1) return false;70 if (socket == 17 && number < 4) return false;71 if (socket == 18 && number < 4) return false;72 if (socket == 19 && number < 1) return false;73 if (socket == 20 && number < 1) return false;74 if (socket == 21 && number < 1) return false;75 if (socket == 22 && number < 1) return false;76 if (socket == 23 && number < 2) return false;77 if (socket == 24 && number < 2) return false;78 if (socket == 25 && number < 1) return false;79 if (socket == 26 && number < 1) return false;80 if (socket == 27 && number < 2) return false;81 if (socket == 28 && number < 2) return false;82 if (socket == 29 && number < 1) return false;83 if (socket == 30 && number < 1) return false;84 if (socket == 31 && number < 2) return false;85 if (socket == 32 && number < 2) return false;86 if (socket == 33 && number < 2) return false;87 if (socket == 34 && number < 2) return false;88 if (socket == 35 && number < 1) return false;89 if (socket == 36 && number < 1) return false;90 if (socket == 37 && number < 5) return false;91 if (socket == 38 && number < 5) return false;92 if (socket == 39 && number < 1) return false;93 if (socket == 40 && number < 1) return false;94 if (socket == 41 && number < 1) return false;95 if (socket == 42 && number < 1) return false;96 if (socket == 43 && number < 1) return false;97 if (socket == 44 && number < 1) return false;98 if (socket == 45 && number < 1) return false;99 if (socket == 46 && number < 1) return false;100 if (socket == 47 && number < 2) return false;101 if (socket == 48 && number < 2) return false;102 if (socket == 49 && number < 3) return false;103 if (socket == 50 && number < 3) return false;104 if (socket == 51 && number < 2) return false;105 if (socket == 52 && number < 2) return false;106 if (socket == 53 && number < 1) return false;107 if (socket == 54 && number < 1) return false;108 if (socket == 55 && number < 1) return false;109 if (socket == 56 && number < 1) return false;110 if (socket == 57 && number < 2) return false;111 if (socket == 58 && number < 2) return false;112 if (socket == 59 && number < 1) return false;113 if (socket == 60 && number < 1) return false;114 if (socket == 61 && number < 1) return false;115 if (socket == 62 && number < 1) return false;116 if (socket == 63 && number < 2) return false;117 if (socket == 64 && number < 2) return false;118 if (socket == 65 && number < 1) return false;119 if (socket == 66 && number < 1) return false;120 if (socket == 67 && number < 3) return false;121 if (socket == 68 && number < 3) return false;122 if (socket == 69 && number < 2) return false;123 if (socket == 70 && number < 2) return false;124 if (socket == 71 && number < 1) return false;125 if (socket == 72 && number < 1) return false;126 if (socket == 73 && number < 1) return false;127 if (socket == 74 && number < 1) return false;128 return true;129}130//номера исползуемые только 1 раз131// 1,2,5,6,7,8,9,10,15,16,19,20,21,22,25,26,29,30, 35,36,39,40,41,42,43,44,45,46,53,54,55,56,59,60,61,62,65,66,71,72,73,74132function join() {133 var L = parseInt(document.getElementById("L").value);134 var R = parseInt(document.getElementById("R").value);135 // проверка на заполненность полей136 if (isNaN(L) && isNaN(R)) {137 document.getElementById("errorText").innerHTML ="Поля не заполнены";138 return;139 } else if (isNaN(L) || isNaN(R)) {140 document.getElementById("errorText").innerHTML ="Поле не заполнено";141 return;142 }143 if (L > R) {144 var tmp = L; // temporary145 L = R;146 R = tmp;147 }148 // проверяем что номер гнезда в диапазоне 1..74149 if (L < 1 || L > 74 || R < 1 || R > 74) {150 document.getElementById("errorText").innerHTML ="Гнезда должны быть в диапазоне 1-74";151 return;152 }153 // проверка на занятость гнезда154 if ( isJoinBusy(L) == true) {155 document.getElementById("errorText").innerHTML ="Гнездо " + L + " занято!";156 return;157 }158 if ( isJoinBusy(R) == true) {159 document.getElementById("errorText").innerHTML ="Гнездо " + R + " занято!";160 return;161 }162 // проверка на занятость розеток163 if(R==27||R==28) {164 if (isSocket2728busy()) {165 //alert("Эта розетка уже занята");166 //console.log("Эта розетка уже занята");167 document.getElementById("errorText").innerHTML = "Розетка 2728 занята";168 return;169 }170 }171 if(R==13 || R==14 || L==13 || L==14) {172 if (isSocket1314busy()) {173 document.getElementById("errorText").innerHTML = "Розетка 1314 занята";174 return;175 }176 }177 // проверка на соединение гнезда с самим собой178 if (L == R) {179 alert('Гнезда должны быть разные!');180 return;181 }182 if (checkDuplicates(L, R) == true) {183 alert("Такое соединение уже есть!");184 return;185 }186 if (L > R) {187 alert('Вводить числа от меньшего к большему!');188 return;189 }190 joins.push({"L": L, "R": R});191 document.getElementById("L").value = '';192 document.getElementById("R").value = '';193 // добавляем новое соединение на экран194 var pairs = document.getElementById("connections").innerHTML;195 pairs = pairs + ('<div class="oval">' + L + '-' + R + "</div>");196 document.getElementById("connections").innerHTML = pairs;197 //фокус обратно на первое поле198 document.getElementById("L").focus();199 document.getElementById("errorText").innerHTML ="";200}201// Функция вызывается когда удаляем соединение202function deleteJoin() {203 var L = parseInt(document.getElementById("Ld").value);204 var R = parseInt(document.getElementById("Rd").value);205 // L = 3 R = 2206 if (L > R) {207 var tmp = L; // temporary208 L = R;209 R = tmp;210 }211 if (isNaN(L) && isNaN(R)) {212 alert('Поля не заполнены!');213 document.getElementById("L").style.borderColor = "red";214 return;215 } else if (isNaN(L) || isNaN(R)) {216 alert('Поле не заполнено!');217 return;218 }219 // проверка на соединение гнезда с самим собой220 if (L == R) {221 alert('Гнезда должны быть разные!');222 return;223 }224 if (checkDuplicates(L, R) != true) {225 alert("Такого соединения не существует!");226 return;227 }228 // deleting..229 var index = -1;230 for (let i = 0; i < joins.length; i++) {231 if (L == joins[i].L && R == joins[i].R){232 index = i;233 }234 }235 if (index > -1) {236 joins.splice(index, 1);237 // deleting from screen238 var connections = document.getElementById("connections");239 connections.innerHTML="";240 for (let i = 0; i < joins.length; i ++) {241 connections.innerHTML += ('<div class="oval">' + joins[i].L + '-' + joins[i].R + "</div>");242 }243 document.getElementById("Ld").value = '';244 document.getElementById("Rd").value = '';245 }246 switchOff();247 // Прокликиваем все кнопки, на случай, если что включено248 mainBtnHandler();249 btnchandelier();250 btnKettle();251 btnGerland();252 btnBell();253 btnTv();254 btnChandelier2();255 btnRecordpleer();256 btnVacuumCleaner();257 btnFloorlamp();258}259// Отключение всего!260function switchOff() {261 // выключаем контрольную лампочку262 document.getElementById("controlLamp").style.backgroundColor = "black";263 controlLamp = 0;264 // выключаем все остальное265 document.getElementById("chandelier").style.backgroundColor = "black";266 //chandelier = 0;267 document.getElementById("linkAudio").pause();268 document.getElementById("linkAudio").currentTime = 0;269 //kettle=0;270 document.getElementById('lamp1').style.backgroundColor='black';271 document.getElementById('lamp2').style.backgroundColor='black';272 document.getElementById('lamp3').style.backgroundColor='black';273 //lamp1=0;274 //lamp2=0;275 //lamp3=0;276 document.getElementById("linkAudio2").pause();277 document.getElementById("linkAudio2").currentTime = 0;278 //bell=0;279 document.getElementById("tv").pause();280 document.getElementById("tv").currentTime = 0;281 //tv=0;282 document.getElementById('lamp5').style.backgroundColor='black';283 document.getElementById('lamp6').style.backgroundColor='black';284 //lamp5=0;285 //lamp6=0;286 document.getElementById("recordplayer").pause();287 document.getElementById("recordplayer").currentTime = 0;288 //recordplayer=0;289 document.getElementById("vacuumcleaner").pause();290 document.getElementById("vacuumcleaner").currentTime = 0;291 //vacuumcleaner=0;292 document.getElementById('floorlamp').style.backgroundColor='black';293 //floorlamp=0;294}295// Button #1296function mainBtnHandler() {297 if (controlLamp == 0298 && checkDuplicates(1, 5) && checkDuplicates(3, 6) && checkDuplicates(2, 4) && checkDuplicates(3, 7) && checkDuplicates(4, 8)) {299 document.getElementById("controlLamp").style.backgroundColor = "red";300 controlLamp = 1;301 } else {302 switchOff();303 }304 // Прокликиваем все кнопки, на случай, если что включено305 //btnchandelier();306 if (controlLamp == 1) {307 if (chandelier == 1) {308 document.getElementById("chandelier").style.backgroundColor = "yellow";309 }310 if (kettle == 1) {311 document.getElementById("linkAudio").play();312 }313 if (lamp1 == 1) {314 document.getElementById('lamp1').style.backgroundColor='green';315 document.getElementById('lamp2').style.backgroundColor='blue';316 document.getElementById('lamp3').style.backgroundColor='purple';317 }318 if (bell == 1) {319 document.getElementById("linkAudio2").play();320 }321 if (tv == 1) {322 document.getElementById("tv").play();323 }324 if (lamp5 == 1) {325 document.getElementById('lamp5').style.backgroundColor='yellow';326 document.getElementById('lamp6').style.backgroundColor='yellow';327 }328 if (recordplayer == 1) {329 document.getElementById("recordplayer").play();330 }331 if (vacuumcleaner == 1) {332 document.getElementById("vacuumcleaner").play();333 }334 if (floorlamp == 1) {335 document.getElementById('floorlamp').style.backgroundColor='yellow';336 }337 }338}339// Button #3340function btnchandelier() {341 if (chandelier == 0 && controlLamp == 1342 && checkDuplicates(3, 17) && checkDuplicates(4, 18) && checkDuplicates(17, 19) && checkDuplicates(16, 20)343 && checkDuplicates(15, 18)) {344 document.getElementById("chandelier").style.backgroundColor = "yellow";345 chandelier = 1;346 } else {347 document.getElementById("chandelier").style.backgroundColor = "black";348 chandelier = 0;349 }350}351function btnKettle() {352 if (controlLamp == 1 && kettle == 0353 && checkDuplicates(3, 17) && checkDuplicates(4, 18) && (checkDuplicates(14, 17)354 && checkDuplicates(13, 18) && checkDuplicates(13, 24) && checkDuplicates(14, 23)) || (checkDuplicates(17, 28)355 && checkDuplicates(18, 27) && checkDuplicates(23, 28) && checkDuplicates(24, 27)) && checkDuplicates(21, 23)356 && checkDuplicates(22, 26) && checkDuplicates(24, 25)357 ) {358 document.getElementById("linkAudio").play();359 kettle=1;360 }else {361 document.getElementById("linkAudio").pause();362 document.getElementById("linkAudio").currentTime = 0;363 kettle=0364 }365}366function btnGerland() {367 if (lamp1==0 && lamp2==0 && lamp3==0368 && controlLamp==1 && checkDuplicates(3, 17) && checkDuplicates(4, 18) && ((checkDuplicates(14, 17)369 && checkDuplicates(13, 18) && checkDuplicates(11,14) && checkDuplicates(12,13))||370 (checkDuplicates(17,28) && checkDuplicates(18, 27) && checkDuplicates(11,28) && checkDuplicates(12,27) )371 ) && checkDuplicates(9,11) && checkDuplicates(10,34) && checkDuplicates(32,34) && checkDuplicates(30, 32) &&372 checkDuplicates(29,31) && checkDuplicates(31,33) && checkDuplicates(12,33)) {373 document.getElementById('lamp1').style.backgroundColor='green';374 document.getElementById('lamp2').style.backgroundColor='blue';375 document.getElementById('lamp3').style.backgroundColor='purple';376 lamp1=1;377 lamp2=1;378 lamp3=1;379 }else {380 document.getElementById('lamp1').style.backgroundColor='black';381 document.getElementById('lamp2').style.backgroundColor='black';382 document.getElementById('lamp3').style.backgroundColor='black';383 lamp1=0;384 lamp2=0;385 lamp3=0;386 }387}388function btnBell() {389 if (controlLamp == 1 && bell == 0390 && checkDuplicates(3,37) && checkDuplicates(4,38) && checkDuplicates(37,41) && checkDuplicates(40,42) &&391 checkDuplicates(38,39)) {392 document.getElementById("linkAudio2").play();393 bell=1;394 }else {395 document.getElementById("linkAudio2").pause();396 document.getElementById("linkAudio2").currentTime = 0;397 bell=0;398 }399}400function btnTv() {401 if (controlLamp == 1 && tv == 0402 && checkDuplicates(3,37) && checkDuplicates(4,38)&&((checkDuplicates(37,68)&&checkDuplicates(38,67)403 &&checkDuplicates(47,68)&&checkDuplicates(48,67))||(checkDuplicates(37,49)&& checkDuplicates(38,50)404 &&checkDuplicates(47,49)&&checkDuplicates(48,50)))&&checkDuplicates(45,47)&&checkDuplicates(44,46)405 &&checkDuplicates(43,48)) {406 document.getElementById("tv").play();407 tv=1;408 }else {409 document.getElementById("tv").pause();410 document.getElementById("tv").currentTime = 0;411 tv=0;412 }413}414function btnChandelier2() {415 if (lamp5==0 && lamp6==0416 && controlLamp==1 &&checkDuplicates(3,37)&&checkDuplicates(4,38)&&checkDuplicates(35,37)417 && checkDuplicates(36,57)&&checkDuplicates(57,59)&&checkDuplicates(58,60)&&checkDuplicates(38,58)) {418 document.getElementById('lamp5').style.backgroundColor='yellow';419 document.getElementById('lamp6').style.backgroundColor='yellow';420 lamp5=1;421 lamp6=1;422 }else {423 document.getElementById('lamp5').style.backgroundColor='black';424 document.getElementById('lamp6').style.backgroundColor='black';425 lamp5=0;426 lamp6=0;427 }428}429function btnRecordpleer() {430 if (controlLamp == 1 && recordplayer == 0431 && checkDuplicates(3,37) && checkDuplicates(4,38)&&((checkDuplicates(37,68)&&checkDuplicates(38,67)432 &&checkDuplicates(51,68)&&checkDuplicates(52,67))||(checkDuplicates(37,49)&& checkDuplicates(38,50)433 &&checkDuplicates(49,51)&&checkDuplicates(50,52))) && checkDuplicates(51,55) && checkDuplicates(54,56)434 && checkDuplicates(52,53)) {435 document.getElementById("recordplayer").play();436 recordplayer=1;437 }else {438 document.getElementById("recordplayer").pause();439 document.getElementById("recordplayer").currentTime = 0;440 recordplayer=0;441 }442}443function btnVacuumCleaner() {444 if (controlLamp == 1 && vacuumcleaner == 0445 && checkDuplicates(3,37) && checkDuplicates(4,38)&&((checkDuplicates(37,68)&&checkDuplicates(38,67)446 &&checkDuplicates(63,68)&&checkDuplicates(64,67))||(checkDuplicates(37,49)&& checkDuplicates(38,50)447 &&checkDuplicates(49,63)&&checkDuplicates(50,64))) && checkDuplicates(61,63)&&checkDuplicates(62,66)448 &&checkDuplicates(64,65)) {449 document.getElementById("vacuumcleaner").play();450 vacuumcleaner=1;451 }else {452 document.getElementById("vacuumcleaner").pause();453 document.getElementById("vacuumcleaner").currentTime = 0;454 vacuumcleaner=0;455 }456}457function btnFloorlamp() {458 if (floorlamp==0 && controlLamp==1459 && checkDuplicates(3,37) && checkDuplicates(4,38)&&((checkDuplicates(37,68)&&checkDuplicates(38,67)460 &&checkDuplicates(68,69)&&checkDuplicates(67,70))||(checkDuplicates(37,49)&& checkDuplicates(38,50)461 &&checkDuplicates(49,69)&&checkDuplicates(50,70)))&&checkDuplicates(69,71)&&checkDuplicates(72,74)462 && checkDuplicates(70,73)) {463 document.getElementById('floorlamp').style.backgroundColor='yellow';464 floorlamp=1;465 }else {466 document.getElementById('floorlamp').style.backgroundColor='black';467 floorlamp=0;468 }}469//Обработчик:Добавление соединений в массив470document.getElementById('btn1').addEventListener('click', join);471// обработчик удаления472document.getElementById('btn1d').addEventListener('click', deleteJoin);473document.getElementById('btn-main').addEventListener('click', mainBtnHandler);474document.getElementById('btn-chandelier').addEventListener('click', btnchandelier);475document.getElementById('btn-kettle').addEventListener('click', btnKettle);476document.getElementById('btn-garland').addEventListener('click', btnGerland);...

Full Screen

Full Screen

delegate.js

Source:delegate.js Github

copy

Full Screen

...91 validUsernameField = 'username';92 validIsDelegateField = 'isDelegate';93 });94 it('should check if username already exists', function (done) {95 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function () {96 expect(accountsMock.getAccount.calledWith({username: validTransaction.asset.delegate.username})).to.be.true;97 done();98 });99 });100 it('should check if sender is already a delegate', function (done) {101 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function () {102 expect(accountsMock.getAccount.calledWith({publicKey: validTransaction.senderPublicKey, isDelegate: 1})).to.be.true;103 done();104 });105 });106 describe('when modules.accounts.getAccount error occurs', function () {107 var validGetAccountErrorMessage;108 beforeEach(function () {109 validGetAccountErrorMessage = 'getAccount error';110 accountsMock.getAccount = sinon.stub().callsArgWith(2, validGetAccountErrorMessage);111 });112 it('should call callback with an error', function (done) {113 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function (err) {114 expect(err).to.equal(validGetAccountErrorMessage);115 done();116 });117 });118 });119 describe('when sender is already a delegate', function () {120 beforeEach(function () {121 accountsMock.getAccount.withArgs({username: node.eAccount.delegateName}, ['username'], sinon.match.any).yields(null, null);122 accountsMock.getAccount.withArgs({publicKey: node.eAccount.publicKey, isDelegate: 1}, ['username'], sinon.match.any).yields(null, node.eAccount);123 });124 it('should call callback with an error', function (done) {125 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function (err) {126 expect(err).to.equal('Account is already a delegate');127 done();128 });129 });130 });131 describe('when username is already registered', function () {132 beforeEach(function () {133 accountsMock.getAccount.withArgs({username: node.eAccount.delegateName}, ['username'], sinon.match.any).yields(null, node.eAccount);134 accountsMock.getAccount.withArgs({publicKey: node.eAccount.publicKey, isDelegate: 1}, ['username'], sinon.match.any).yields(null, null);135 });136 it('should call callback with an error', function (done) {137 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function (err) {138 expect(err).to.equal('Username ' + validTransaction.asset.delegate.username + ' already exists');139 done();140 });141 });142 });143 describe('when delegate is already registered with the same username', function () {144 beforeEach(function () {145 accountsMock.getAccount.withArgs({username: node.eAccount.delegateName}, ['username'], sinon.match.any).yields(null, node.eAccount);146 accountsMock.getAccount.withArgs({publicKey: node.eAccount.publicKey, isDelegate: 1}, ['username'], sinon.match.any).yields(null, node.eAccount);147 });148 it('should call callback with an error', function (done) {149 delegate.checkDuplicates(validTransaction, validUsernameField, validIsDelegateField, function (err) {150 expect(err).to.equal('Account is already a delegate');151 done();152 });153 });154 });155 });156 describe('checkConfirmed', function () {157 var validUsername;158 var checkDuplicatesStub;159 var transactionsExceptionsIndexOfStub;160 beforeEach(function () {161 validUsername = validSender.username;162 checkDuplicatesStub = sinon.stub(delegate, 'checkDuplicates').callsArg(3);163 transactionsExceptionsIndexOfStub = sinon.spy(exceptions.delegates, 'indexOf');...

Full Screen

Full Screen

checkSubmission.js

Source:checkSubmission.js Github

copy

Full Screen

1class CheckSubmission {2 constructor(sudokuPuzzle){3 this.sudokuPuzzle = sudokuPuzzle4 }5 checkDuplicates(array) {6 const containDuplicates = array.some(7 (val, i) => array.indexOf(val) !== i8 )9 return containDuplicates10 }11 checkRow() {12 let row1 = []13 let row2 = []14 let row3 = []15 let row4 = []16 let row5 = []17 let row6 = []18 let row7 = []19 let row8 = []20 let row9 = []21 for(let x = 0; x < 3; x++) {22 row1.push(this.sudokuPuzzle.box1[x])23 row2.push(this.sudokuPuzzle.box1[x+3])24 row3.push(this.sudokuPuzzle.box1[x+6])25 row4.push(this.sudokuPuzzle.box4[x])26 row5.push(this.sudokuPuzzle.box4[x+3])27 row6.push(this.sudokuPuzzle.box4[x+6])28 row7.push(this.sudokuPuzzle.box7[x])29 row8.push(this.sudokuPuzzle.box7[x+3])30 row9.push(this.sudokuPuzzle.box7[x+6])31 }32 for(let x = 0; x < 3; x++) {33 row1.push(this.sudokuPuzzle.box2[x])34 row2.push(this.sudokuPuzzle.box2[x+3])35 row3.push(this.sudokuPuzzle.box2[x+6])36 row4.push(this.sudokuPuzzle.box5[x])37 row5.push(this.sudokuPuzzle.box5[x+3])38 row6.push(this.sudokuPuzzle.box5[x+6])39 row7.push(this.sudokuPuzzle.box8[x])40 row8.push(this.sudokuPuzzle.box8[x+3])41 row9.push(this.sudokuPuzzle.box8[x+6])42 }43 for(let x = 0; x < 3; x++) {44 row1.push(this.sudokuPuzzle.box3[x])45 row2.push(this.sudokuPuzzle.box3[x+3])46 row3.push(this.sudokuPuzzle.box3[x+6])47 row4.push(this.sudokuPuzzle.box6[x])48 row5.push(this.sudokuPuzzle.box6[x+3])49 row6.push(this.sudokuPuzzle.box6[x+6])50 row7.push(this.sudokuPuzzle.box9[x])51 row8.push(this.sudokuPuzzle.box9[x+3])52 row9.push(this.sudokuPuzzle.box9[x+6])53 }54 if(!this.checkDuplicates(row1) &&55 !this.checkDuplicates(row2) &&56 !this.checkDuplicates(row3) &&57 !this.checkDuplicates(row4) &&58 !this.checkDuplicates(row5) &&59 !this.checkDuplicates(row6) &&60 !this.checkDuplicates(row7) &&61 !this.checkDuplicates(row8) &&62 !this.checkDuplicates(row9)63 ){64 return true65 } else {66 return false67 }68 }69 checkColumn() {70 let column1 = []71 let column2 = []72 let column3 = []73 let column4 = []74 let column5 = []75 let column6 = []76 let column7 = []77 let column8 = []78 let column9 = []79 for(let x = 0; x< 7; x+=3){80 column1.push(this.sudokuPuzzle.box1[x])81 column2.push(this.sudokuPuzzle.box1[x+1])82 column3.push(this.sudokuPuzzle.box1[x+2])83 column4.push(this.sudokuPuzzle.box2[x])84 column5.push(this.sudokuPuzzle.box2[x+1])85 column6.push(this.sudokuPuzzle.box2[x+2])86 column7.push(this.sudokuPuzzle.box3[x])87 column8.push(this.sudokuPuzzle.box3[x+1])88 column9.push(this.sudokuPuzzle.box3[x+2])89 }90 91 for(let x= 0; x< 7; x+=3){92 column1.push(this.sudokuPuzzle.box4[x])93 column2.push(this.sudokuPuzzle.box4[x+1])94 column3.push(this.sudokuPuzzle.box4[x+2])95 column4.push(this.sudokuPuzzle.box5[x])96 column5.push(this.sudokuPuzzle.box5[x+1])97 column6.push(this.sudokuPuzzle.box5[x+2])98 column7.push(this.sudokuPuzzle.box6[x])99 column8.push(this.sudokuPuzzle.box6[x+1])100 column9.push(this.sudokuPuzzle.box6[x+2])101 }102 for(let x= 0; x< 7; x+=3){103 column1.push(this.sudokuPuzzle.box7[x])104 column2.push(this.sudokuPuzzle.box7[x+1])105 column3.push(this.sudokuPuzzle.box7[x+2])106 column4.push(this.sudokuPuzzle.box8[x])107 column5.push(this.sudokuPuzzle.box8[x+1])108 column6.push(this.sudokuPuzzle.box8[x+2])109 column7.push(this.sudokuPuzzle.box9[x])110 column8.push(this.sudokuPuzzle.box9[x+1])111 column9.push(this.sudokuPuzzle.box9[x+2])112 }113 if(!this.checkDuplicates(column1) &&114 !this.checkDuplicates(column2) &&115 !this.checkDuplicates(column3) &&116 !this.checkDuplicates(column4) &&117 !this.checkDuplicates(column5) &&118 !this.checkDuplicates(column6) &&119 !this.checkDuplicates(column7) &&120 !this.checkDuplicates(column8) &&121 !this.checkDuplicates(column9)122 ){123 return true124 } else {125 console.log(column1)126 return false127 }128 }129 checkBox() {130 if(131 !this.checkDuplicates(this.sudokuPuzzle.box1) &&132 !this.checkDuplicates(this.sudokuPuzzle.box2) &&133 !this.checkDuplicates(this.sudokuPuzzle.box3) &&134 !this.checkDuplicates(this.sudokuPuzzle.box4) &&135 !this.checkDuplicates(this.sudokuPuzzle.box5) &&136 !this.checkDuplicates(this.sudokuPuzzle.box6) &&137 !this.checkDuplicates(this.sudokuPuzzle.box7) &&138 !this.checkDuplicates(this.sudokuPuzzle.box8) &&139 !this.checkDuplicates(this.sudokuPuzzle.box9)140 )141 {142 return true143 } else {144 return false145 }146 }147 get isCorrect() {148 if( this.checkBox() && this.checkRow() && this.checkColumn() ){149 return true150 } else{151 return false152 }153 }...

Full Screen

Full Screen

addToArray.js

Source:addToArray.js Github

copy

Full Screen

1import defaultValue from "../../Core/defaultValue.js";2/**3 * Adds an element to an array and returns the element's index.4 *5 * @param {Array} array The array to add to.6 * @param {Object} element The element to add.7 * @param {Boolean} [checkDuplicates=false] When <code>true</code>, if a duplicate element is found its index is returned and <code>element</code> is not added to the array.8 *9 * @private10 */11function addToArray(array, element, checkDuplicates) {12 checkDuplicates = defaultValue(checkDuplicates, false);13 if (checkDuplicates) {14 const index = array.indexOf(element);15 if (index > -1) {16 return index;17 }18 }19 array.push(element);20 return array.length - 1;21}...

Full Screen

Full Screen

challenge-36.js

Source:challenge-36.js Github

copy

Full Screen

1/*2-create a variable named checkDuplicates and assign it the value of an emptry array literal3-call the split method of str with ('') as it's argument and assign it's value to splitStr4-call the forEach method of splitStr with element as it's argument5 -if the includes method of checkDuplicates with element as it's argument is false:6 -call the push method of checkDuplicates with element as it's argument7-return checkDuplicates.length8*/9function solution(str) {10 const checkDuplicates = [];11 splitStr = str.split('')12 splitStr.forEach((element) => {13 if (!checkDuplicates.includes(element)) {14 checkDuplicates.push(element);15 }16 })17 return checkDuplicates.length...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4(async () => {5 const browser = await puppeteer.launch();6 const page = await browser.newPage();7 await page.goto('

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer-extra');2const StealthPlugin = require('puppeteer-extra-plugin-stealth');3puppeteer.use(StealthPlugin());4(async () => {5 const browser = await puppeteer.launch({ headless: false });6 const page = await browser.newPage();7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const hasDuplicates = await page.evaluate(() => {6 return checkDuplicates();7 });8 console.log(hasDuplicates);9 await browser.close();10})();11const puppeteer = require('puppeteer');12(async () => {13 const browser = await puppeteer.launch();14 const page = await browser.newPage();15 const hasDuplicates = await page.evaluate(() => {16 return checkDuplicates();17 });18 console.log(hasDuplicates);19 await browser.close();20})();21const puppeteer = require('puppeteer');22(async () => {23 const browser = await puppeteer.launch();24 const page = await browser.newPage();25 const hasDuplicates = await page.evaluate(() => {26 return checkDuplicates();27 });28 console.log(hasDuplicates);29 await browser.close();30})();31const puppeteer = require('puppeteer');32(async () => {33 const browser = await puppeteer.launch();34 const page = await browser.newPage();35 const hasDuplicates = await page.evaluate(() => {36 return checkDuplicates();37 });38 console.log(hasDuplicates);39 await browser.close();40})();41const puppeteer = require('puppeteer');42(async () => {43 const browser = await puppeteer.launch();44 const page = await browser.newPage();45 const hasDuplicates = await page.evaluate(() => {46 return checkDuplicates();47 });48 console.log(hasDuplicates);49 await browser.close();50})();51const puppeteer = require('puppeteer');52(async () => {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful