Frontend Developer Interview Questions

8,967 frontend developer interview questions shared by candidates

Pair programming test: Requirements: 1. Write a function that takes (`london/leeds`) and returns an object in this shape. { journeyTitle: string; originStationName: string; originStationId: string; destinationStationName: string; destinationStationId: string; price: number } 2. Add a 20% surcharge for London. The data you get will be: [ { id: '1', name: 'London', slug: 'london', }, { id: '2', name: 'Manchester', slug: 'manchester', }, { id: '3', name: 'Leeds', slug: 'leeds', }, { id: '4', name: 'York', slug: 'york', }, ]; For example: getJourneyInfo('london/leeds'); will output { journeyTitle: 'London to Leeds; originStationName: 'London'; originStationId: '1'; destinationStationName: 'Leeds'; destinationStationId: '4'; price: 100 } They will ask you to write jest unit test for your function and will ask what else can you test? (think edge cases like `london/london` argument). Finally, they will ask you if you can think of any optimisations you can do to make it faster? (you can change the data from array to key-value object so you can just pick out the slug you want instead of looping).
avatar

Frontend Developer

Interviewed at Trainline

3.8
Jul 16, 2022

Pair programming test: Requirements: 1. Write a function that takes (`london/leeds`) and returns an object in this shape. { journeyTitle: string; originStationName: string; originStationId: string; destinationStationName: string; destinationStationId: string; price: number } 2. Add a 20% surcharge for London. The data you get will be: [ { id: '1', name: 'London', slug: 'london', }, { id: '2', name: 'Manchester', slug: 'manchester', }, { id: '3', name: 'Leeds', slug: 'leeds', }, { id: '4', name: 'York', slug: 'york', }, ]; For example: getJourneyInfo('london/leeds'); will output { journeyTitle: 'London to Leeds; originStationName: 'London'; originStationId: '1'; destinationStationName: 'Leeds'; destinationStationId: '4'; price: 100 } They will ask you to write jest unit test for your function and will ask what else can you test? (think edge cases like `london/london` argument). Finally, they will ask you if you can think of any optimisations you can do to make it faster? (you can change the data from array to key-value object so you can just pick out the slug you want instead of looping).

Viewing 6801 - 6810 interview questions

Glassdoor has 8,967 interview questions and reports from Frontend developer interviews. Prepare for your interview. Get hired. Love your job.