-1

I'm doing to subtract inside the json is this possible?

 @employees = [
{
  "name": "Fullname1"
  "vl": "Vacation Leave",
  "vl_days": "15.0",
  "sl": "Sick Leave",
  "sl_days": "10.0",
  "bday": "Birthday",
  "b_day":"1.0",
  "credit_vl":"12.0",
  "use_vl": "vl_days - credit_vl"
}
wiwit
  • 73
  • 1
  • 7
  • 26
  • [Adding and Subtracting with Javascript and JSON](http://stackoverflow.com/questions/9220301/adding-and-subtracting-with-javascript-and-json) – prasanth Nov 09 '16 at 05:08
  • 2
    no it is not possible ... because 1) `use_v1` will be a string and 2) you don't have json there, you have a javascript object, 3) the var `@employees` is not a valid javascript object name, as `@` is not a legal character in a javascript object and 4) you forgot the closing `]` ... so all in all, no chance at all – Jaromanda X Nov 09 '16 at 05:12
  • 5) no comma after `"name": "Fullname1"` – Jaromanda X Nov 09 '16 at 05:25
  • 1
    Congratulations, you have won the prize for the most number of typos in a single post. –  Nov 09 '16 at 05:28
  • I don't think 5 comes close - maybe today's prize :p – Jaromanda X Nov 09 '16 at 05:30

1 Answers1

1

i am assuming ]in your question . without this it is not possible.

 employees = [
{
  "name": "Fullname1",
  "vl": "Vacation Leave",
  "vl_days": "15.0",
  "sl": "Sick Leave",
  "sl_days": "10.0",
  "bday": "Birthday",
  "b_day":"1.0",
  "credit_vl":"12.0"
}];
var use_vl=(employees[0].vl_days-employees[0].credit_vl);
 employees[0].use_vl=use_vl;

console.log(employees);
Mahi
  • 1,707
  • 11
  • 22