if
조건이있는 JavaScript를 사용하여 변수의 값을 확인하고 싶습니다 . 이 경우 변수의 값 location
은 var location="Banglore"
입니다. 그러나 매번 다른 부분으로 가십시오.
내 코드는
var location="Banglore";
if(typeof(location)== "Bangalore")
{
var data_file = "http://api.openweathermap.org/data/2.5/
find? q=Bangalore&units=metric";
}
else if(typeof(location) == "Chennai")
{
var data_file = "http://api.openweathermap.org/data/2.5/
find?q=Chennai&units=metric";
}
else if(typeof(location) == "Cochi")
{
var data_file = "http://api.openweathermap.org/data/2.5/
find? q=Cochi&units=metric";
}
else
{
var data_file = "http://api.openweathermap.org/data/2.5/
find?q=Pune&units=metric";
}
이 코드에서 항상 다른 부분, 즉 위치 == pune 상태로 이동하십시오.
위치를 'Banglore'로 설정하고 'if'조건은 'Bangalore'입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다