I have this snippet code below. For me I think this is a long method. Is there any short method for this? Thanks
var aaa = '1:00 AM'
var bbb = aaa.split(" ");
var ccc = bbb,
ddd = bbb;
<input type ="textbox" id = "time">
First of all, better variable names would greatly help future developers.
aaa carries almost no meaning.
Secondly, just make your expressions more direct. Save variables for when you need to break your code into smaller chunks:
var time = '1:00 AM'.split(" "); var hour = time, twelve_hour_suffix = time; $("#time").val(twelve_hour_suffix);
There are a lot of ways to make it shorter (even single-liners), but I feel this is sufficiently small and direct that readers will understand it easily.