Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Is this the right coding?

Asked by
natru2 0
8 years ago

if("Jon".length * 2 / (2+1) == 2 ) { console.log("The answer makes sense") } else if("jon".length * 2 / (2+1) >=2) { console.log("the answer is nagative") }

and is this there another way the script can be chaged

1 answer

Log in to vote
0
Answered by 8 years ago

What you're writing is JavaScript. Here's how you could do the above in Lua.

if(string.len("Jon") * 2 / (2+1) == 2) then
    print("The answer makes sense")
elseif(string.len("jon") * 2 / (2+1) >= 2) then
    print("the answer is nagative")
end

Syntax-wise, rather than { and } brackets, which are used in many OOP languages like JavaScript, Lua uses a replacement for these in most cases...

{ can be a few keywords, like then, do, and others. } is usually end, though it isn't used after each part of an if statement.

Good luck! I hope this helps.

Ad

Answer this question