Search Posts

Category: underscore.js

library mismatch in lodash and underscore.js

i’m using an angular framework in my project which uses lodash library but also loading a dojo framework code which uses the underscorejs library, inside an iframe. How do i ensure that the functions execute from the correct library, i.e. angular –> lodash functions and dojo –> underscore.js functions, since currently the underscore functions under dojo are fetching the lodash library? Source: AngularJS

Sort an object array by custom order

I have an array of objects which have a property called ‘CODE’. [ { ID: 168, NAME: “First name”, CODE: “AD” }, { ID: 167, NAME: “Second name”, CODE: “CC” }, { ID: 169, NAME: “Third name”, CODE: “CCM” }, { ID: 170, NAME: “Fourth name”, CODE: “CR” }, ] How do I order the array by a customized order like: var item_order = [“CCM”,”CR”,”AD”,”CC”]; Been trying various methods with no success. Please help. Source: […]

print like this * "a" -> "a1" * "aabbbaa" -> "a2b3a2"

I am new to js. can you tell me how to print like this * “a” -> “a1” * “aabbbaa” -> “a2b3a2” i tried with hash map but test cases failing. providing my code below. i am not good in hash map. can you tell me how to solve with hash map so that in future I can fix it my self. not sure what data structure to use for this one. providing my code […]

Merge two Arrays using underscore.js in AngularJS

I have two api requests and both gets a result of JSON. The first request is “account” request and second is “Container” request. Now: Request for all Accounts (accountid: 1, name: account1, blabla) Request for all Containers (accountid: 1, name: Container1, blabla) This is the result JSON of Accounts: account: [ { accountId: “123456789”, fingerprint: null, name: “Account2”, path: “accounts/123456789”, }, This is the result JSON of Containers: { accountId: “123456789”, containerId: “123****”, domainName: null, […]