javascript,简单如果其他语句

问题描述:

我刚开始使用JavaScript,我想帮助这个基本的if/else语句。我相信语法是关闭的?我需要它来阅读真实。javascript,简单如果其他语句

if ("Jon".length * 2/(2+1) ===) 
{ 
     console.log("The answer makes sense!") 
} 
else 
{ 
    console.log("Error Error Error") 
} 
+0

如果( “乔恩”。长度* 2 /(2 + 1)===) { 的console.log( “答案是有道理的!” ); } else { console.log('Error Error Error'); } } –

+0

它很接近,但你需要完成if。也许你打算说'if(“Jon”.length * 2 /(2 + 1)=== 2)'? – *eth

+1

欢迎来到SO。好的,你有一个if语句,你想检查什么条件?如果你在'==='右边有一个数字,这个表达式将被评估为真/假,这就是你要找的。问题是这个数字是什么? – Christos

工作代码为:

<script> 
if ("Jon".length * 2/(2+1) === 2) 
{ 
    console.log("The answer makes sense!"); //or 
    //alert("The answer makes sense!"); 
} 
else 
{ 
    console.log("Error Error Error"); //or 
    //alert("Error Error Error"); 
} 
</script>