---
title: "Comment by fengxh on \"Rust for JavaScript Developers\" | Hashnode"
description: "I&#39;m sorry, but there is an error in javascript code about ternary operator let age = 17 if (age &gt;= 18 ){ console .log( \" You are old enough to vote\" ); }"
url: "https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c"
---

[Discussion](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342)

Comment [Rust for JavaScript Developers](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342)

[fengxh](https://hashnode.com/@fengxh)

[May 22, 2020](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c)

I'm sorry, but there is an error in javascript code about `ternary operator`

```
let age = 17 
if(age >= 18){
    console.log(" You are old enough to vote");
}else{
   console.log("Come back when you are 18");
}

// Ternary Operator 
if age >= 18 ? console.log(" You are old enough to vote") : console.log("Come back when you are 18");
// here we don't need if identifier, just remove it
```

[j](https://hashnode.com/@chilimatic)

[May 22, 2020](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c#reply-5ec79a6a627c645c120ad402)

I would also mention that If/match in rust are expressions and not ternary operators. also other comparisons are not a 100% correct. but that's normal in the beginning.

[Abimbola Oladele](https://hashnode.com/@consoledot)

[May 22, 2020](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c#reply-5ec79aa2a7a2c43b12374d79)

Thanks for pointing out the Error, didn't even notice it. Editing now

[Abimbola Oladele](https://hashnode.com/@consoledot)

[May 22, 2020](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c#reply-5ec79ba7627c645c120ad412)

Yes they are not ternary operators, it's just the closet thing I could compare with JavaScript syntax. Thanks for pointing it out. [j](https://hashnode.com/@chilimatic)

[j](https://hashnode.com/@chilimatic)

[May 22, 2020](https://hashnode.com/posts/rust-for-javascript-developers/5ec6a0c6a7a2c43b12374342/comment/5ec75d38627c645c120acf4c#reply-5ec79e31627c645c120ad426)

[Abimbola Oladele](https://hashnode.com/@vilagedeveloper) I know, that's why I didn't mention it on the first read, but since some one else pointed it out. Also match is not a switch but ... for the sake of a javascript perspective you could use it that way :D true.

anyhow good article, I don't want to sidetrack to much :)
