Sirma JavaScript Test 2023
Sirma JavaScript Test 2023
Name: ________________________________________________________________________________________________________________
Each question in the test has exactly one correct answer. The correct answer shall be marked with a circle over the letter.
The last question is a coding challenge.
1. In what sequence will the letters be printed to the console when 2. What will be printed to the console when the following code is
the following code is executed: executed:
Answers: Answers:
1
3. What will be printed to the console when the following code is 4. What will be printed to the console when the following code is
executed: executed:
Answers: Answers:
A) true, false, false, true, false, false A) 7 9 0
B) false, false, false, false, false, false B) 5 6 7 8 9 10 6
C) true, false, true, false, false, true C) 6 7 8 9 10 5
D) false, false, true, true, false, false D) 7 9 2
E) true, false, true, true, false, true E) 6 7 8 9 4
F) true, false, false, true, false, true F) 6 7 8 9 10 0
2
5. What will be printed to the console when the following code is 6. What will be printed to the console when the following code is
executed: executed:
3
7. The funcA function takes an object containing airport information and returns all departing flights greater than 500 miles. Analyze the code and
choose the correct form of the proper ‘airport’ object.
function funcA(airport) {
const distance = 500;
const thisAirportCode = airport.airportCode;
const arrivingAndDeparturingFlights = airport.flights;
const flightDistance = 'distanceInMiles';
const departuringFlights = [];
return departuringFlights;
}
4
Answers to task 7:
A. { D. {
fromAirportWithCode: 'SOF', airportCode: 'SOF',
to: 'FRA', airport: {
distanceInMiles: 1007, flights: {
} fromAirportWithCode: 'SOF',
to: 'FRA',
B. { distanceInMiles: 1007
airportCode: 'SOF', }
flights: { },
length: 5, }
fromAirportWithCode: 'SOF',
to: 'FRA', E. {
distanceInMiles: 1007, thisAirportCode: 'SOF',
}, arrivingAndDeparturingFlights: [
} {
fromAirportWithCode: 'SOF',
C. [ to: 'FRA',
{ flightDistance: 1007
fromAirportWithCode: 'SOF', },
to: 'FRA', ],
distanceInMiles: 1007, }
}, F. {
{ airportCode: 'SOF',
fromAirportWithCode: 'SOF', flights: [
to: 'FRA', {
distanceInMiles: 1007, fromAirportWithCode: 'SOF',
}, to: 'FRA',
] distanceInMiles: 1007
},
],
}
5
8. The variable ‘data‘ contains an array of objects, each object containing information about different foods. The function in which the variable
‘data’ is passed looks for a combination of two different foods with a total caloric value of fewer than 500 calories After the function is
executed, the following is printed in the console:
cheeseburger with 410 calories + french fries with 365 calories make a great meal for under 500 calories.
This answer is wrong (410 + 365 > 500) because there is a logic bug in the function. Mark in the answers, the number of the line where you
think the bug in the question is located:
const data = [
{ name: 'cheeseburger', weight: 156, calories: 410 },
{ name: 'french fries', weight: 117, calories: 365 },
{ name: 'spaghetti', weight: 56, calories: 207 },
{ name: 'banana', weight: 125, calories: 111 },
{ name: 'watermelon', weight: 286, calories: 86 },
{ name: 'pork sausage', weight: 48, calories: 163 },
{ name: 'bacon', weight: 26, calories: 106 },
];
6
Function to task 8:
1. function funcA(foodList) {
2. if (foodList.length < 2) {
3. return null;
4. }
5. let firstFood = null;
6. let secondFood = null;
7.
8. for (let i = 0; i <= foodList.length - 1; i++) {
9. firstFood = foodList[i];
10. for (let j = i + 1; j < foodList.length; j++) {
11. secondFood = foodList[j];
12. if (firstFood.weight + secondFood.weight < 500) {
13. return (
firstFood.name + ' with ' + firstFood.calories + ' calories + ' +
secondFood.name + ' with ' + secondFood.calories +
' calories make a great meal for under 500 calories.'
);
14. }
15. }
16. }
17. return 'There are no two different foods with a sum of their calories less than 500.';
18. }
19. funcA(data);
Answers to task 8:
A) 2 B) 8 C) 9 D) 10 E) 11 F) 12
7
{
9. The variable ‘cvList’ contains an array of objects. Each object candidate: {
contains information from a job applicant’s CV. The function ‘funcA’ name: 'Maria',
validates this data and prints to the console the names of the email: 'maria.tomson@gmail.com',
candidates who successfully pass the validation. The function will print age: 29
only one name. What is it? },
workExperience: [],
},
const cvList = [
{
{
candidate: {
candidate: {
name: 'Tom', name: 'Sofia',
email: 'sofia.vergara@gmail.com',
email: 'tom.tol@gmail.com',
age: 21
age: 35
}
},
},
workExperience: [
{
{
candidate: {
company: 'Bosch',
name: 'Pam',
durationInYears: 1
email: 'pamela.a@gmail.com',
}
age: 30
],
},
},
workExperience: [
{
{
candidate: {
name: 'Tyler', company: 'Tesla',
durationInYears: 2
email: 'tyler.lanister@gmail.com',
}
},
],
workExperience: [
},
{
];
company: 'Twitter',
durationInYears: 5
}
],
},
8
Function to task 9:
function funcA(data) {
if (!data || data.length < 1) {
return;
}
Answers to task 9:
A) Tom
B) Tyler
C) Maria
D) Sofia
E) Pam
F) No name will be printed
9
10. You have html code with the following structure:
B. .container {
<div class="container">
position: relative;
<div class="item">A</div>
width: 300px;
<div class="item">B</div> height: 20px;
<div class="item">C</div> border: 1px solid black;
}
</div>
.item {
Result in the browser: position: absolute;
top: 0;
padding-left: 5px;
}
Guess what CSS code was used to produce this result in the browser? C. .container {
width: 300px;
Answers to task 10:
}
A. .container {
.item {
position: relative;
margin-left: 5px;
width: 300px;
width: 50px;
height: 20px;
height: 20px;
border: 1px solid black;
border: 1px solid black;
}
display: block;
.item {
}
display: block;
left: 5px;
}
10
Answers to task 10:
D. .container { F. .container {
width: 300px; width: 300px;
} height: 20px;
.item { position: relative;
margin-left: 5px; }
border: 1px solid black; .item {
display: inline-block; width: 50px;
} height: 20px;
border: 1px solid black;
E. .container {
position: absolute;
position: relative;
top: 0;
width: 300px;
left: 5px;
height: 20px;
}
}
.item {
border: 1px solid black;
position: absolute;
top: 0;
padding-left: 5px;
}
11
11. You have HTML code from which several attributes have been deleted. Which of the answers below fits best to the attributes?
The attributes in the answers are arranged in order - 1,2,3,4.
<form>
<a 1="https://sirma.com/">This is a link</a>
<img 2="avatar.png" />
<p 3="background-color:red;width:100px;">Hello World</p>
<input 4="submit" value="Submit" />
</form>
Answers: A) href, defer, src, type B) type, onchange, title, source C) href, href, style, style
D) href, src, style, type E) value, src, href, novalidate F) type, src, novalidate, src
You can write the code on the back of the sheet. Code checking is not strict. Forgotten semicolons or minor syntax errors are acceptable.
12