Description: The following pseudo code is intended to print numbers from 1 to 10, but it runs indefinitely. Identify and fix the issue.
functionprintNumbers(){leti=1letj=0while(i<=10){console.log(i)j++}}Challenge: Fix the loop so it terminates correctly.
Description:
Find the final value of ans by tracing the code step-by-step,
f=(x)=>2*xg=(y)=>3*y+1ans=0result=0n=2for(i=1;i<5;i++){result=ans*2||2}while(n>0){ans=g(ans)n=n-2}if(f(2)<g(0)){ans=g(0)+result}Consider the file ab.js
exportclassA{constructor(){this.x=0}increment(){return++this.x}}constnewA=newA()exportconsta=newAexportfunctionmakeA(){returnnewA()}then file main.js
import{a,makeA}from"./ab.js"functionexecute(){constb=makeA()console.log(a.increment())console.log(b.increment())}execute()execute()what is output result of second execute()
We are trying to scale this Express service
queue.consume(msg=>{sendSMS(msg)})cron(*12***){sendEmail()}app.get('/service',async(req,res)=>{return ...
})Are there any problem if we install load balancer and scale this service from 1 to 4 instances
constf=()=>{thrownewError("X")}constg=()=>{Promise.resolve().then(()=>{console.log("E")thrownewError("F")}).finally(()=>{thrownewError("G")})}console.log("A")try{f()console.log("B")}catch{console.log("C")}console.log("D")try{g()thrownewError("H")}catch{console.log("I")thrownewError("J")}console.log("K")What is the output printed to console
let's assume that we have some dummy bank account service
letbalance=0functiondeposit(x){returnnewPromise(resolve=>setTimeout(()=>{balance+=x;resolve(balance)},Math.random()*10))}functionwithdraw(x){returnnewPromise(resolve=>setTimeout(()=>{if(balance>=x)balance-=x;resolve(balance)},Math.random()*10))}constresult=awaitPromise.all([deposit(100),deposit(20),withdraw(120),])console.log("balance:",balance)What is the output?