Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Question 1
- *
- * a) What will be logged to the console?
- * b) How could the params in the call to getData be changed in order to log something else?
- */
- var getData = function(params) {
- if (typeof params.accountNumber !== 'number') {
- return Promise.reject({message: 'accountNumber must be of type: number'});
- } else {
- return Promise.resolve({foo: 'foo'});
- }
- };
- getData({accountNumber: '1234'})
- .then(function(response) {
- console.log(response.foo);
- })
- .catch(function(error) {
- console.log(error.message);
- });
- /**
- * Question 2
- *
- * Create a function that receives an array of credit card data and then:
- * a) filters out cards that end in 9
- * b) sorts the cards first by roleTypeCode, then by cardNumber
- */
- var cardsList = [
- {fullName: 'Star, Patrick', roleTypeCode: '03', cardNumber: '223456'},
- {fullName: 'Squarepants, Spongebob', roleTypeCode: '01', cardNumber: '987654'},
- {fullName: 'Tentacles, Squidward', roleTypeCode: '02', cardNumber: '765432'},
- {fullName: 'Tentacles, Squidward', roleTypeCode: '02', cardNumber: '465439'},
- {fullName: 'Star, Patrick', roleTypeCode: '03', cardNumber: '123456'}
- ];
- /**
- * Question 3
- *
- * Create a function that receives a list of field configurations and a map of field id's and their values that
- * iterates through the list of fields and:
- * a) sets a field's message property to 'Field is required' if the map of field values has a falsy value for the field's id
- * b) removes the message property from a field if its value in the map of field values is truthy
- */
- var fieldConfigs = [
- {
- id: 'date',
- label: 'Date',
- inputType: 'date',
- options: {
- minDaysFromToday: 0
- },
- message: 'Field successfully updated'
- },
- {
- id: 'lastName',
- label: 'First Name',
- inputType: 'text',
- maxLength: 40,
- required: true
- },
- {
- id: 'firstName',
- label: 'First Name',
- inputType: 'text',
- maxLength: 40,
- required: true
- }
- ];
- var data = {
- date: '2020-01-01',
- lastName: 'Squarepants',
- firstName: ''
- };
Add Comment
Please, Sign In to add comment