早教吧 育儿知识 作业答案 考试题库 百科 知识分享

语法variablename=(condition)?value1:value2例子greeting=(visitor=="PRES")?"DearPresident":"Dear";如果变量visitor中的值是"PRES",则向变量greeting赋值"DearPresident",否则赋值"Dear".教程里边写的,

题目详情
语法variablename=(condition)?value1:value2
例子greeting=(visitor=="PRES")?"Dear President ":"Dear ";
如果变量 visitor 中的值是 "PRES",则向变量 greeting 赋值 "Dear President ",否则赋值 "Dear".
教程里边写的,
▼优质解答
答案和解析
if (visitor == "PRES"){
greeting= "Dear President ";
} else /* if(visitor != "PRES") */{
greeting="Dear ";
}