I have the code:
if (votes > tmp) tmp = votes;
It does what it says on the tin: if var1 > var0 then var0 = var1
Is there a cleaner way to write this in Javascript?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
Math.maxif you feel it’s cleaner…A comment below seems to suggest that you need the max of an Array.
If so, you can do this…
Or if you need to include the current
tmpvalue, you can concat it in…