1
출력은 "화요일 7월 정의, 정의되지 않은 26, 2016 화요일"여기 출력이 어디로가는 지 "정의되지 않은"용어가있는 이유는 무엇입니까?
내 코드는 "화요일, 7월 26, 2016"과 같이 한 다음 "즐길"하지만 그 대신, 그것은 처럼 보이는한다 : var today = new Date();function getMonth1(today) {
if(today.getMonth() == 0) {
console.log("January");
}
else if(today.getMonth() == 1) {
console.log("February");
}
else if(today.getMonth() == 2) {
console.log("March");
}
else if(today.getMonth() == 3) {
console.log("April");
}
else if(today.getMonth() == 4) {
console.log("May");
}
else if(today.getMonth() == 5) {
console.log("June");
}
else if(today.getMonth() == 6) {
console.log("July");
}
else if(today.getMonth() == 7) {
console.log("August");
}
else if(today.getMonth() == 8) {
console.log("September");
}
else if(today.getMonth() == 9) {
console.log("October");
}
else if(today.getMonth() == 10) {
console.log("November");
}
else if(today.getMonth() == 11) {
console.log("December");
}
}
function getWeekday(today) {
if(today.getDay() == 0) {
console.log("Sunday");
}
else if(today.getDay() == 1) {
console.log("Monday");
}
else if(today.getDay() == 2) {
console.log("Tuesday");
}
else if(today.getDay() == 3) {
console.log("Wednesday");
}
else if(today.getDay() == 4) {
console.log("Thursday");
}
else if(today.getDay() == 5) {
console.log("Friday");
}
else if(today.getDay() == 6) {
console.log("Saturday");
}
}
function getDate1(today) {
console.log(getWeekday(today) + "," + getMonth1(today), today.getDate(), ",", today.getFullYear());
if(getWeekday(today) == "Tuesday") {
console.log("enjoy");
}
}
getDate1 (오늘);
getMonth1 및 getWeekDay 함수는 정의되지 않은 함수를 반환합니다.이 함수에서'console.log' 대신 값을'return '해야합니다 ... 현재 출력이 3 행 이상인 것을 볼 수 있습니다. 귀하의 질문에 제안 된 –
그래서 당신은 내가 "돌아 가기"getMonth1 및 getWeekday 함수의 "console.log"를 모두 바꾸어야한다고 말하는거야? –
정확히 내가 말한 것입니다. –