- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 02:39 AM
Please write a code to print name and number from the below in javascript.
{ department : "IT Admin", user details : { {name:"ravi", number:"65839"}, {name:"rahul", number:"44499"} } }
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 02:19 AM
Hi @snowsid88 ,
As per my understanding, here is the code
Var data = {
department: "IT Admin",
"user details": [
{ name: "ravi", number: "65839" },
{ name: "rahul", number: "44499" }
]
};
data["user details"].forEach(function(user) {
console.log("Name: " + user.name + ", Number: " + user.number);
});
Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
Thank You
AJ - TechTrek with AJ - ITOM Trainer
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
Topmate:- https://topmate.io/aj_techtrekwithaj (Connect for 1-1 Session)
ServiceNow Community MVP 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 10:24 AM
Hi @snowsid88
May you try this
var data = {
department: "IT Admin",
user_details: [
{ name: "ravi", number: "65839" },
{ name: "rahul", number: "44499" }
]
};
data.user_details.forEach(user => {
gs.log("Name:", user.name);
gs.log("Number:", user.number);
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 02:19 AM
Hi @snowsid88 ,
As per my understanding, here is the code
Var data = {
department: "IT Admin",
"user details": [
{ name: "ravi", number: "65839" },
{ name: "rahul", number: "44499" }
]
};
data["user details"].forEach(function(user) {
console.log("Name: " + user.name + ", Number: " + user.number);
});
Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
Thank You
AJ - TechTrek with AJ - ITOM Trainer
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
Topmate:- https://topmate.io/aj_techtrekwithaj (Connect for 1-1 Session)
ServiceNow Community MVP 2025