1

When i run this code in visual studio in shows me error..but i run this code in other code editor it is working fine.

// code....
var account = {
  name: "john",
  income: 0,
  expense: 0
};

//add income
var addIncome = function(myAccount, inc = 34) {
  myAccount.income += inc;
  return myAccount.income;
};

var addInc = addIncome(account);
console.log(addInc);    
var addExpense = function(myAccount, exp = 0) {
  myAccount.expense += exp;
  return myAccount.expense;
};

var addExp = addExpense(account, 1000);
console.log(addExp);
var getAccountSummary = function(myAccount) {
    console.log(`in my account total income is: ${myAccount.income} and my expense:${myAccount.expense}');
};
getAccountSummary(account);
console.log(account);

1 Answer 1

2

You are using mismatched quotes on this line:

console.log(`in my account total income is: ${myAccount.income} and my expense:${myAccount.expense}');

Note that you start the string with a backtick, but end with a single quote. Try replacing the single quote with a backtick:

console.log(`in my account total income is: ${myAccount.income} and my expense:${myAccount.expense}`);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.