Is there a shorter way to write this?
var ttt = "dd";
if (ttt.length < 3)
ttt= "i" + ttt;
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.
Yours is pretty short, but if you want to use the the conditional operator (a.k.a the ternary operator), you could do the following:
… or if bytes are really precious (code golfing?), you could also do something like this:
… but then that could be reduced to just:
… as @Nick Craver suggested in a comment below.