添加对象的元素并存储在对象中

时间:2019-06-19 15:08:04

标签: javascript

我们正在创建一个对象,该对象用于将数据传递给验证函数时对其进行验证。我们想提供对象中包含的元素的总价值。

var TestDataAmountsInitial = {
  "TestNumner1": 34.98,
  "TestNumner2": 10.00,
  "TestTotal": this.TestNumner1 + this.TestNumner2
};

// logging output 

it(`----------------------------------------`, () => {
    console.log("DEBUG: Test Data");
    console.log(`The Data: TestNumner1:  ${TestDataAmountsInitial.TestNumner1}`);
    console.log(`The Data: TestNumner2:  ${TestDataAmountsInitial.TestNumner2}`);
    console.log(`The Data: TestTotal:  ${TestDataAmountsInitial.TestTotal}`);
  });

// Console output 

DEBUG: Test Data
The Data: TestNumner1:  34.98
The Data: TestNumner2:  10
The Data: TestTotal:  NaN

0 个答案:

没有答案