Best JavaScript code snippet using wpt
ABC085C.js
Source: ABC085C.js
1// inputã«å
¥åãã¼ã¿å
¨ä½ãå
¥ã2function Main(input) {3 input = input.split(" ");4 var N = parseInt(input[0]);5 var Y = parseInt(input[1]);6 var A = 0;7 var B = 0;8 var C = 0;9 if(10000*N < Y || 1000*N > Y){10 console.log("-1 -1 -1");11 }12 else{13 var tmpC = Y%5000/1000;14 C = tmpC;15 Y -= 1000*tmpC;16 N -= tmpC;17 var tmp = Y/5000;18 B = tmp;19 if(tmp == N){20 console.log(A+" "+B+" "+C);21 }22 else if(tmp > N){23 A = tmp - N;24 B = tmp - A*2;25 if(A > N + tmpC || B < 0){26 console.log("-1 -1 -1");27 }28 else{29 console.log(A+" "+B+" "+C);30 }31 }32 else{33 switch((N - tmp)%4){34 case 0:35 B = tmp - (N - tmp)/4;36 C += (N - tmp)/4*5;37 if(B < 0 || C > N + tmpC){38 console.log("-1 -1 -1");39 }40 else{41 console.log(A+" "+B+" "+C);42 }43 break;44 case 1:45 B = tmp - Math.floor((N - tmp)/4);46 C += Math.floor((N - tmp)/4)*5;47 A += 3;48 B -= 7;49 C += 5;50 if(A > N + tmpC || B < 0 || C > N + tmpC){51 console.log("-1 -1 -1");52 }53 else{54 console.log(A+" "+B+" "+C);55 }56 break;57 case 2:58 B = tmp - Math.floor((N - tmp)/4);59 C += Math.floor((N - tmp)/4)*5;60 A += 2;61 B -= 5;62 C += 5;63 if(A > N + tmpC || B < 0 || C > N + tmpC){64 console.log("-1 -1 -1");65 }66 else{67 console.log(A+" "+B+" "+C);68 }69 break;70 case 3:71 B = tmp - Math.floor((N - tmp)/4);72 C += Math.floor((N - tmp)/4)*5;73 A += 1;74 B -= 3;75 C += 5;76 if(A > N + tmpC || B < 0 || C > N + tmpC){77 console.log("-1 -1 -1");78 }79 else{80 console.log(A+" "+B+" "+C);81 }82 break;83 }84 }85 }86}87//*ãã®è¡ä»¥éã¯ç·¨éããªãã§ãã ããï¼æ¨æºå
¥åºåããä¸åº¦ã«èªã¿è¾¼ã¿ãMainãå¼ã³åºãã¾ãï¼...
modal_html.js
Source: modal_html.js
1var MODAL_HTML = {2 _confirm: function(id, t, c, l, f) { //è¾åºconfirmçhtml代ç 3 var dom_id = id;4 var tmp = '';5 tmp += '<div class="am-modal am-modal-confirm" tabindex="-1" id="' + dom_id + '">';6 tmp += ' <div class="am-modal-dialog">';7 tmp += ' <div class="am-modal-hd">{title}<span data-am-modal-close class="am-close"><i class="am-icon-times-circle"></i></span></div>';8 tmp += ' <div class="am-modal-bd">{content}</div>';9 tmp += ' <div class="am-modal-footer">';10 tmp += ' <span class="am-modal-btn" data-am-modal-cancel>{cancel}</span>';11 tmp += ' <span class="am-modal-btn" data-am-modal-confirm>{confirm}</span>';12 tmp += ' </div>';13 tmp += ' </div>';14 tmp += '</div>';15 tmp = tmp.replace('{title}', t);16 tmp = tmp.replace('{content}', c);17 tmp = tmp.replace('{cancel}', l);18 tmp = tmp.replace('{confirm}', f);19 if ($("#" + dom_id).length > 0) {20 $("#" + dom_id).remove();21 }22 $("body").append(tmp);23 },24 _alert: function(id, t, c, f) {25 var dom_id = id;26 var tmp = '';27 tmp += '<div class="am-modal am-modal-alert" tabindex="-1" id="' + dom_id + '">';28 tmp += ' <div class="am-modal-dialog">';29 tmp += ' <div class="am-modal-hd">{title}</div>';30 tmp += ' <div class="am-modal-bd">{content}</div>';31 tmp += ' <div class="am-modal-footer">';32 tmp += ' <span class="am-modal-btn">{confirm}</span>';33 tmp += ' </div>';34 tmp += ' </div>';35 tmp += '</div>';36 tmp = tmp.replace('{title}', t);37 tmp = tmp.replace('{content}', c);38 tmp = tmp.replace('{confirm}', f);39 if ($("#" + dom_id).length > 0) {40 $("#" + dom_id).remove();41 }42 $("body").append(tmp);43 },44 _prompt: function(id, t, c, l, f) {45 var dom_id = id;46 var tmp = '';47 tmp += '<div class="am-modal am-modal-prompt" tabindex="-1" id="' + dom_id + '">';48 tmp += ' <div class="am-modal-dialog">';49 tmp += ' <div class="am-modal-hd">{title}</div>';50 tmp += ' <div class="am-modal-bd">{content}<input type="text" class="am-modal-prompt-input"></div>';51 tmp += ' <div class="am-modal-footer">';52 tmp += ' <span class="am-modal-btn" data-am-modal-cancel>{cancel}</span>';53 tmp += ' <span class="am-modal-btn" data-am-modal-confirm>{confirm}</span>';54 tmp += ' </div>';55 tmp += ' </div>';56 tmp += '</div>';57 tmp = tmp.replace('{title}', t);58 tmp = tmp.replace('{content}', c);59 tmp = tmp.replace('{cancel}', l);60 tmp = tmp.replace('{confirm}', f);61 if ($("#" + dom_id).length > 0) {62 $("#" + dom_id).remove();63 }64 $("body").append(tmp);65 }...
bai6.js
Source: bai6.js
1/**2 * 3 */4//bai1-phiếu 15 var can = ["Canh", "Tân", "Nhâm", "QuÃ", "Giáp", "Ất", "Binh", "Äinh", "Máºu", "Ká»·"];6 var chi = ["Thân", "Dáºu", "Tuất", "Hợi", "Tý", "Sá»u", "Dần", "Mão", "Thìn", "Tỵ", "Ngá»", "Mùi"];7function result(){8 var tmp = document.getElementById("duong");9 var x = parseInt(tmp.value);10 var tmpCan = can[x % 10];11 var tmpChi = chi[parseInt((x % 60) % 12)];12 document.getElementById("am").innerHTML = tmpCan + " " + tmpChi;13}14//bà i 2 phiếu 115 var sum = 0;16 var temp = 0;17 18function bam(x) {19 temp = x;20}21function kq() {22 document.getElementById("kq").textContent = sum + temp;23 24 sum = 0;25 temp = 0;26}27function plus() {28 sum += temp;29}30//bà i 2 phiếu 231function tru() {32 sum += temp;33}34function kqt() {35 document.getElementById("kqt").textContent = sum - temp;36 37 sum = 0;38 temp = 0;39}40//bà i 1-phiếu 241function PTB2() {42 var a = document.getElementById("a");43 var b = document.getElementById("b");44 var c = document.getElementById("c");45 46 var tmpA = a.value;47 var tmpB = b.value;48 var tmpC = c.value;49 var x1, x2;50 51 var del = tmpB * tmpB - 4 * tmpA * tmpC;52 53 if(del < 0) {54 document.getElementById("kq").innerHTML ="Phương trình vô nghiá»m";55 tmpA = tmpB = tmpC =0;56 }57 else {58 document.getElementById("kq").innerHTML ="Phương trình hai nghiá»m: <br>x1 = " + ((-tmpB + Math.sqrt(del)) / (2 * tmpA)) + "<br>x2 = " + ((-tmpB - Math.sqrt(del)) / (2 * tmpA));59 tmpA = tmpB = tmpC =0;60 }61}62//bà i 1 phiếu 363function PTB1() {64 var a1 = document.getElementById("a1");65 var b1 = document.getElementById("b1");66 var c1 = document.getElementById("c1");67 var a2 = document.getElementById("a2");68 var b2 = document.getElementById("b2");69 var c2 = document.getElementById("c2");70 71 var tmpA1 = a1.value;72 var tmpB1 = b1.value;73 var tmpC1 = c1.value;74 var tmpA2 = a2.value;75 var tmpB2 = b2.value;76 var tmpC2 = c2.value;77 78 document.getElementById("Gptb1").innerHTML= "Nghiá»m cá»§a phương trình là : <br>x = " + ((tmpC1 - tmpB1 * (tmpA2 * tmpC1 - tmpA1 * tmpC2)/(tmpA2 * tmpB1 - tmpA1*tmpB2))/tmpA1) + "<br>y = " + ((tmpA2 * tmpC1 - tmpA1 * tmpC2)/(tmpA2 * tmpB1 - tmpA1*tmpB2));79}80//bà i 2 phiếu 381function check() {82 var tmp = document.getElementById("number");83 if(tmp.value > 0 && tmp.value <= 10) {84 var kq = document.getElementById("check");85 kq.textContent="Dữ liá»u Äúng";86 }87 else {88 document.getElementById("check").textContent="Dữ liá»u không Äúng";89 }...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('Test ID:', data.data.testId);6 console.log('Test URL:', data.data.summary);7 console.log('View results:', data.data.userUrl);8});9### new WebPageTest(host, key, options)
Using AI Code Generation
1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 console.log('Test ID: ' + data.data.testId);6 console.log('Test results available at: ' + data.data.summaryCSV);7});8var wpt = require('webpagetest');9var client = wpt('www.webpagetest.org');10 if (err) return console.error(err);11 console.log('Test status: ' + data.statusText);12 console.log('Test ID: ' + data.data.testId);13 console.log('Test results available at: ' + data.data.summaryCSV);14});15var wpt = require('webpagetest');16var client = wpt('www.webpagetest.org');17 if (err) return console.error(err);18 console.log('Test status: ' + data.statusText);19 console.log('Test ID: ' + data.data.testId);20 console.log('Test results available at: ' + data.data.summaryCSV);21});22var wpt = require('webpagetest');23var client = wpt('www.webpagetest.org');24 if (err) return console.error(err);25 console.log('Test status: ' + data.statusText);26 console.log('Test ID: ' + data.data.testId);27 console.log('Test results available at: ' + data.data.summaryCSV);28});29var wpt = require('webpagetest');30var client = wpt('www.webpagetest.org');31 if (
Check out the latest blogs from LambdaTest on this topic:
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
Mobile apps have been an inseparable part of daily lives. Every business wants to be part of the ever-growing digital world and stay ahead of the competition by developing unique and stable applications.
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
Continuous integration is a coding philosophy and set of practices that encourage development teams to make small code changes and check them into a version control repository regularly. Most modern applications necessitate the development of code across multiple platforms and tools, so teams require a consistent mechanism for integrating and validating changes. Continuous integration creates an automated way for developers to build, package, and test their applications. A consistent integration process encourages developers to commit code changes more frequently, resulting in improved collaboration and code quality.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!