FE-Interview question with answers
/**
extensions is an Array and each item has such format:
{firstName: 'xxx', lastName: 'xxx', ext: 'xxx', extType: 'xxx'}
lastName, ext can be empty, extType can only has "DigitalUser", "VitrualUser","FaxUser","Dept","AO".
**/
/**
Question 1: sort extensions by "firstName" + "lastName" + "ext" ASC
**/
/**
Question 2: sort extensions by extType follow these orders ASC
DigitalUser < VitrualUser < FaxUser < AO < Dept.
**/
/**
saleItems is an Array has each item has such format:
{
month: n, //[1-12],
date: n, //[1-31],
transationId: "xxx",
salePrice: number
}
**/
/**
Question 3: write a function to calculate and return a list of total sales (sum) for each quarter, expected result like:
[
{quarter: 1, totalPrices: xxx, transactionNums: n},
{....}
]
**/
/**
Question 4: write a function to calculate and return a list of average sales for each quarter, expected result like:
[
{quarter: 1, averagePrices: xxx, transactionNums: n},
{....}
]
**/
/**
Question 5: please create a tool to generate Sequence
Expected to be used like:
var sequence1 = new Sequence();
sequence1.next() --> return 1;
sequence1.next() --> return 2;
in another module:
var sequence2 = new Sequence();
sequence2.next() --> 3;
sequence2.next() --> 4;
**/
/**
Question 6:
AllKeys: 0-9;
usedKeys: an array to store all used keys like [2,3,4];
We want to get an array which contains all the unused keys,in this example it would be: [0,1,5,6,7,8,9]
**/