I have an Object
obj
as below:
const obj = { Hostname: "abc" id: 189883 message: "error message" name: "script name" };
- I want to exclude the key
Hostname
and it value. - I only want to capture the
values
excludingkeys
such that the output looks as below:189883:error message:script name
The final output should be a string
.
I have written the following code but it is creating array element for every letter
const resultObj = Object.values(vascoResponse.rows[0]obj).map((row) => Object.values(row).filter((val) => val) );
Advertisement
Answer
Use Object.values()
const objec = { Hostname: "abc", id: 189883, message: "error message", name: "script name" }; res = Object.values(objec).filter((o,i) => o != "abc" ).join(":") console.log(res)