0
var employee = ["Sam", "John", "Mark", "Peter", "Simon"]

var department = ["Sales", "Marketting", "Operation", "Finance", "Tech"]

var salary  = [40000, 60000, 50000, 60000, 70000]
const data=new Object(department,employee,salary);

console.log(data);

Why only print departments value?

Gass
  • 7,536
  • 3
  • 37
  • 41
  • 3
    Why are you using [`new Object`](//developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/Object) in the first place? What do you expect `new Object(a, b, c)` to do and why? – Sebastian Simon Jan 20 '22 at 04:27
  • how to store three array in single object @SebastianSimon – Ramanjeet Singh Jan 20 '22 at 04:55
  • Familiarize yourself with [how to access and process nested objects, arrays or JSON](/q/11922383/4642212) and how to [create objects](//developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Object_initializer). This is explained in every [JS tutorial about objects](//developer.mozilla.org/docs/Web/JavaScript/Guide/Working_with_Objects). – Sebastian Simon Jan 20 '22 at 04:57

2 Answers2

0

var employee = ["Sam", "John", "Mark", "Peter", "Simon"]

var department = ["Sales", "Marketting", "Operation", "Finance", "Tech"]

var salary = [40000, 60000, 50000, 60000, 70000] 

const data={department,employee,salary};
console.log(data)
krystallix
  • 121
  • 7
-1

Enclose the values by curly braces

const data = {department, employee, salary};
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Vignesh
  • 302
  • 3
  • 12
  • 1
    See "[Explaining entirely code-based answers](https://meta.stackoverflow.com/q/392712/128421)". While this might be technically correct it doesn't explain why it solves the problem or should be the selected answer. We should educate in addition to help solve the problem. – the Tin Man Jan 21 '22 at 23:05
  • Please just [edit] in the future to make corrections. Do have extended discussions in the comments. – General Grievance Jan 24 '22 at 14:09