首页 > 解决方案 > Getting "Undefined" value for Variable even though i have defined variable

问题描述

HI I have defined variable called "const VA" but in output it is coming undefine cause of that i am not able to see values inside it below is my code.

function createAddress(streetA, cityA, zipcodeA) {
  return
  {
    streetA, cityA, zipcodeA;
  }
}
const VA = createAddress("405", "newyork", "123456");
console.log(VA);

Output is undefined

标签: javascript

解决方案


.之后的括号不能有换行符return。改用这个:

return {
    value,
    value2,
    value3
}

推荐阅读