Created
February 24, 2019 20:07
-
-
Save juandaveth/6ddd4cdca56e6a8536bdaa22eb35c17a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newArray.forEach(element => { | |
const lineArray = element.split("/"); | |
lineArray.forEach((code, index) => { | |
// Distrito code: | |
const first = code.split(" "); | |
// Distrito name, using function for cases with two words: | |
function add(isUndefined) { | |
return lineArray[2].split(" ")[3] || ''; | |
} | |
listDistName = `${lineArray[2].split(" ")[2]} ${add(true)}`; | |
// Provincia code: | |
const lineProvCode = lineArray[1].split(" ")[1]; | |
// Provincia name: | |
const lineProvName = lineArray[1].split(" ")[2]; | |
if (index === 2) { | |
const obj = { | |
codigo: first[1], | |
listDistName, | |
lineProvCode, | |
lineProvName, | |
} | |
if (obj.codigo.length > 0) { | |
dist.push(obj); | |
} | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment