Próbuję uzyskać nazwę tablicy podczas przełączania wewnątrz tablicy tablic,
Tutaj tablica
roles: [
Operational = [
"Drives cloud standards for adopting cloud services to ensure consistency.",
"Provide regular, clear, and consistent communication (written and oral) on the status of projects, issues, and deliverables to representatives from the customer/vendor.",
"Develop and maintain understanding of key processes, schedules, cycles, profiles, etc. for the technical systems in use by a customer.",
"Work with IT and Business management to evaluate complex user requests, large projects and strategies.",
"Perform analysis of large-scale, complex, cross-system, cross-platform changes or issues.",
],
Acquisition = [
"Work with cloud vendors to evaluate and select services that can support agile business requirements",
"Prepare ROI analysis and assist with creating budget proposals to initiate the acquisition of cloud services",
"Mitigate significant risks associated with large cloud projects, which have a hig",
"complexity and/or involve significant challenges to the business and systems",
"Partner with internal teams and cloud vendors on software and hardware selection and produce and present cost and value benefit analyses",
]
],
Chcę przechodzić przez role i dla każdego indeksu chcę uzyskać nazwy i zawartość w tej tablicy. Na przykład Operacyjne: 1) 2) 3) Nabycie: 1) 2) itd. Tak dalej
Jestem w stanie wyświetlić wartości wewnątrz każdego indeksu tablicy, gdy nie mam pojęcia, jak uzyskać nazwy, takie jak Operacyjne, Pozyskiwanie do wyświetlenia.
Oto co próbowałem.
jobOffer.roles.forEach((role, index) => {
role.forEach(rol => {
roles += `<li style="padding: 8px 0px 8px 0px; color: #000;">${rol}</li>`
})
});
Wszelkie sugestie będą bardzo mile widziane.
0
imLohith
18 marzec 2020, 08:37
2 odpowiedzi
Najlepsza odpowiedź
Myślę, że powinieneś ponownie sformatować swoją tablicę
roles: [
{ Operational: [
"Drives cloud standards for adopting cloud services to ensure consistency.",
"Provide regular, clear, and consistent communication (written and oral) on the status of projects, issues, and deliverables to representatives from the customer/vendor.",
"Develop and maintain understanding of key processes, schedules, cycles, profiles, etc. for the technical systems in use by a customer.",
"Work with IT and Business management to evaluate complex user requests, large projects and strategies.",
"Perform analysis of large-scale, complex, cross-system, cross-platform changes or issues.",
] },
{ Acquisition: [
"Work with cloud vendors to evaluate and select services that can support agile business requirements",
"Prepare ROI analysis and assist with creating budget proposals to initiate the acquisition of cloud services",
"Mitigate significant risks associated with large cloud projects, which have a hig",
"complexity and/or involve significant challenges to the business and systems",
"Partner with internal teams and cloud vendors on software and hardware selection and produce and present cost and value benefit analyses",
] },
],
1
iamhuynq
18 marzec 2020, 05:43
Najpierw musisz zmienić format zgodnie z sugestią @iamhuynq.
Wtedy możesz zdobyć takie klucze
roles.map(a => {
console.log(Object.keys(a)[0]) // key
console.log(a) // object
)
Albo możesz zmienić taką strukturę
roles = {
Operational: [
"Drives cloud standards for adopting cloud services to ensure consistency.",
"Provide regular, clear, and consistent communication (written and oral) on the status of projects, issues, and deliverables to representatives from the customer/vendor.",
"Develop and maintain understanding of key processes, schedules, cycles, profiles, etc. for the technical systems in use by a customer.",
"Work with IT and Business management to evaluate complex user requests, large projects and strategies.",
"Perform analysis of large-scale, complex, cross-system, cross-platform changes or issues.",
],
Acquisition: [
"Work with cloud vendors to evaluate and select services that can support agile business requirements",
"Prepare ROI analysis and assist with creating budget proposals to initiate the acquisition of cloud services",
"Mitigate significant risks associated with large cloud projects, which have a hig",
"complexity and/or involve significant challenges to the business and systems",
"Partner with internal teams and cloud vendors on software and hardware selection and produce and present cost and value benefit analyses",
]
};
I zdobądź takie klucze
Object.keys(roles).map(a => {
console.log(a) // key
console.log(roles[a]) // object
})
Dzięki
0
Qubaish Bhatti
18 marzec 2020, 05:57