<div class="container">
<div class="question">
<h3> Question 1: Code lines: 5-19. What the alert message will be shown when you click on the button <h3>
<button class="button button-1" role="button" onclick="question1()">Question 1</button>
</div>
<div class="question">
<h3> Question 2: Code lines: 25-39. What the alert message will be shown when you click on the buttons <h3>
<button class="button button-2" role="button" onclick="question21()">Question 2 - Case 1 </button>
<button class="button button-3" role="button" onclick="question22()">Question 2 - Case 2 </button>
</div>
<div class="question">
<h3> Question 3: Code lines: 44-49. What the alert message will be shown when you click on the buttons <h3>
<button class="button button-1" role="button" onclick="question3(1)">Question 3 2</button>
</div>
<div class="question">
<h3> Question 4: Code lines: 54-84. In you opinion, what is the issue of the code? </h3>
</div>
</div>
/*
Question 1:
*/
function question1() {
function bar() {
return 10;
}
alert(bar());
function bar() {
return 100;
}
var bar = function () {
return 1000;
};
}
/*
Question 2: What will be printed to console
*/
const payfareQuestion2 = {
interviewQuestion: "Payfare Interview Question 2",
print: function () {
alert(this.interviewQuestion);
}
};
function question21() {
payfareQuestion2.print();
}
function question22() {
setTimeout(payfareQuestion2.print, 0);
}
/*
Question 3: what will be printed to console
*/
function question3(currentNumber) {
setTimeout(function () {
alert(`the question number is: ${currentNumber}`);
}, 0);
currentNumber += 1;
}
// question3(1) // the question number is: ???
/*
Question 4: In you opinion, what is the issue of the following code
*/
const SERVICES = {
bishop: {
url: "bishop://"
},
gibson: {
url: "gibson://"
}
};
function callApi(url) {
// Calling api success will be randomly
const mockSuccess = Math.round(Math.random());
return mockSuccess;
}
function makeRequest(serviceName, maxRetry) {
const service = SERVICES[serviceName];
const { url } = service;
const isSuccess = callApi(url);
if (isSuccess) return "Success";
// try apiCall
if (!service.retried || service.retried < maxRetry) {
service.retried ||= 0;
service.retried += 1;
return makeRequest(serviceName, maxRetry);
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.