๐ My Agoda Frontend Interview Experience | 82 LPA | Senior Software Engineer
Overview
Agoda, a global travel platform based in Singapore, seeks Frontend Engineers proficient in building scalable UI features using React/React Native. Ideal candidates should demonstrate expertise in implementing pixel-perfect designs, ensuring optimal performance, and collaborating effectively within international teams. The interview process assesses candidates' skills in JavaScript, TypeScript, and related frontend technologies.
Interview Rounds
The interview process comprised two main rounds:
Round 1: Machine Coding
-
Language: JavaScript
-
Platform: HackerRank
-
Duration: 90 minutes
-
Problem Statement: Implement an immutable copy functionality for a JavaScript class.
The candidate was required to enhance a given
MyClasswith methods to:getImmutableCopy(): Returns an immutable copy of the instance, preventing modification of propertiesa,b, andc.isMutable(): Returns a boolean indicating whether the object is mutable.
The provided code template was as follows:
class MyClass { constructor(a, b, c, mutable = true) { this.a = a; this.b = b; this.c = c; this._mutable = mutable; } sum() { return this.a + this.b + this.c; } isMutable() { return this._mutable; } getImmutableCopy() { const clone = new MyClass(this.a, this.b, this.c, false); return Object.freeze(clone); } } // Example usage: const input = '1 2 3'; // Replace this with actual input const [a, b, c] = input.split(' ').map(Number); const obj = new MyClass(a, b, c); console.log(obj instanceof MyClass); // true console.log(obj.isMutable()); // true const immutableObj = obj.getImmutableCopy(); console.log(immutableObj.isMutable()); // falseThe final working solution involved utilizing
Object.freeze()to create an immutable copy. The importance of shallow freezing was highlighted, noting that deeply nested objects would require recursive freezing for full immutability./** * ๐ง JavaScript Note: * Object.freeze() only freezes the object at the top level. * For deeply nested immutability, you'd need a recursive deep freeze. */ class MyClass { constructor(a, b, c, mutable = true) { this.a = a; this.b = b; this.c = c; this._mutable = mutable; // Flag to check mutability } // ๐ข Returns sum of a, b, and c sum() { return this.a + this.b + this.c; } /** * Returns an immutable copy of the object. * Uses Object.freeze() to make it read-only. */ getImmutableCopy() { const frozen = new MyClass(this.a, this.b, this.c, false); return Object.freeze(frozen); // ๐ง Object becomes read-only } /** * Returns whether the current instance is mutable. */ isMutable() { return this._mutable; } } // ๐งช HackerRank Input & Output Logic function main() { const input = require('fs').readFileSync(0, 'utf-8').trim().split(' '); const [a, b, c] = input.map(Number); const obj = new MyClass(a, b, c); const immutableCopy = obj.getImmutableCopy(); // โ This modification won't apply on frozen object try { immutableCopy.a = 999; } catch (e) {} // โ Output the required flags console.log(obj.a === a && obj.b === b && obj.c === c); // true console.log(obj.isMutable()); // true console.log(immutableCopy.isMutable()); // false }
Round 2: Multiple Choice Questions (MCQs)
-
Number of Questions: 5
-
Focus: TypeScript and JavaScript fundamentals
The MCQs covered topics such as:
- TypeScript String Type: Understanding the difference between
String(object wrapper) andstring(primitive). - Interface Extending a Class: Demonstrating knowledge of how TypeScript interfaces can extend classes.
- Interface Implementation with Class: Correctly implementing an interface in a class, including proper
thisbinding. - React Native Button Props: Identifying valid and type-safe definitions for React Native button properties.
- JavaScript Promise Execution Order: Predicting the output of JavaScript code involving promises and
setTimeout.
- TypeScript String Type: Understanding the difference between
Key Takeaways
- Timing Matters: Candidates should prioritize completing assessments early within the given timeframe.
- Solid Fundamentals: A strong understanding of JavaScript and TypeScript is crucial for Agoda's frontend roles.
- Code Quality: Clean, well-commented, and maintainable code is highly valued.
- Immutability: Understanding and implementing immutability in JavaScript is essential.
Despite answering all questions correctly, the candidate was rejected, potentially due to the timing of their submission. This highlights the importance of promptly addressing interview assessments to maximize opportunities.
Original Source
This experience was originally published on medium. Support the author by visiting the original post.
Read on medium