function convert(s) { console.log(s);//hi s +=s.toUpperCase(); console.log(s);//hiHI}function funny(s) { convert(s); console.log(s);//hi}funny('hi');//求问为什么第三个是hi吗?为什么不是hiHI
1 回答
慕姐4208626
TA贡献1852条经验 获得超7个赞
function convert(otherStr) {
console.log(otherStr);//hi
otherStr += otherStr.toUpperCase();
console.log(otherStr);//hiHI
}
function funny(str) {
convert(str);
console.log(str);//hi
}
funny('hi');
不知道这样是不是能看明白一点
另外如果想第三个想输出hiHI可以吧代码改成如下
function convert(otherStr) {
console.log(otherStr);//hi
otherStr += otherStr.toUpperCase();
console.log(otherStr);//hiHI
return otherStr
}
function funny(str) {
//用一个变量来接收convert返回的值,当然也可以不接收直接打印出来
var res = convert(str);
console.log(res);//hiHI
}
funny('hi');
添加回答
举报
0/150
提交
取消
