Write a function that will recursively merge two objects with the following conditions: 1.) If a[field] is an array, and b[field] is defined and is not an array, add b[field] to the array 2.) If a[field] is an array an b[field] exists but is undefined or null, set a[field] to an empty array 3.) If a[filed] is an array and b[field] is an array, set a[field] to b[field] 4.) If a[field] exists and b[field] exists but is undefined, delete a[field] 5.) If b[field] is a non-complex type (number, string, boolean, et cetera), copy to a[field] Example: var a = { first_name: 'Bob', last_name: 'Joness', email: 'bob@gmail.com', address: { line_1: '1234 Main St', line_2: 'Apt 413', city: 'Los Angeles', state: 'CA', zip: '90048' }, logins: [ { date: '10/22/2012', ip: '192.168.0.1' }, { date: '10/21/2012', ip: '192.168.0.1' } ], photos: [ 'IMG-1985.jpg', 'IMG-1987.jpg' ] } var b = { last_name: 'Jones', active: true, address: { line_1: '2143 South Main St', line_2: undefined }, logins: { date: '10/23/2012', ip: '192.168.0.1' }, photos: undefined } Result: { first_name: 'Bob', last_name: 'Jones', active: true, email: 'bob@gmail.com', address: { line_1: '2143 South Main St', city: 'Los Angeles', state: 'CA', zip: '90048' }, logins: [ { date: '10/22/2012', ip: '192.168.0.1' }, { date: '10/21/2012', ip: '192.168.0.1' }, { date: '10/23/2012', ip: '192.168.0.1' } ], photos: [] } Assumptions: 1.) You can assume you are working in node; e.g. you have access to array methods such as .some and .forEach, and you do not have to worry about browser compatibility issues 2.) You do not have access to utilities such as lodash or underscore
Node Interview Questions
1,043 node interview questions shared by candidates
Its kind of pair programming, the interviewer asked to build a component in react for showing progress bar, next asked to write code for downloading data from external api and converting the files with yaml extension to json.
A possibilidade de contratação PJ ?
one of them was showed a javascript code what it will print and why?
Destructuring in JavaScript and write a code how to destructure an object?
Theory basic on js and node js basic programs: Palindrome, Fibonacci, Factorial, etc
Performance issues with Node.js. Explain the single-threaded model in Node.js
Fale sobre sua trajetória. Com quais linguagens já trabalhou. Quais projetos se orgulha. Qual empresa ou projeto foi frustrante.
Previous experience. and expectations
Async await, promises and callbacks
Viewing 1021 - 1030 interview questions