
        do {
            day = prompt('Day');
            if (!day_regex.test(day)) alert('Day not correct..!');
        } while(!day_regex.test(day))
        info = prompt('Info');
        addDiv(day, info);
    }

Is it possible to improve the clarity of this code, without affecting its functionality?

A:

I wrote this up using a lot more jQuery as an example. Confirmed working JSFiddle here.
You can see there's a considerably less lines of code, there's less boilerplate on each line (things like document.getElementsByTagName), and at least in my opinion it's a lot more expressive.
Additionally, it becomes much easier to do other things that jQuery does well. For example, to animate these toggles. Just change $hidden.toggle() to $hidden.slideToggle()
Full code:
'use strict';

function enterData(){
    var day, info, day_regex = /[A-Z][a-z]{1,7} [1-9][0-9]?, 2[0-9]{3}/;
    do {
        day = prompt('Day');
        if (!day_regex.test(day)) alert('Day not correct..!');
    } while(!day_regex.test(day))
    info = prompt('Info');
    addDiv(day, info);
}

function bindEventsToEl( $trigger, $hidden, events ){

    //This lets you pass in a different hash of events to bind, if you wanted to
    var eventsHash = events || {
        click: function(){
            $hidden.toggle();
        }
    };

    for ( var event_type in eventsHash ){
        $trigger.on( event_type, eventsHash[event_type] );
    }
}

function defineTriggers(hide) {
    var $hidden = $("div"),
        $triggers = $("h2");

    if (hide) {
        $hidden.hide();

        $triggers.each(function(i,el){
            bindEventsToEl( $(el), $( $hidden[i] ) );
        });
    }
}

function addDiv(date,
do { 
             day = prompt('Day'); 
             if (! day_regex.test(day) ) alert('Day not correct.. !'); 
         } while(!day_regex.test(day) ) 
         info = prompt('Info'); 
         addDiv(day, information); 
     } 

 Is it potential to better the clarity of this code, without involve its functionality? 

 vitamin a: 

 I wrote this up using a draw more jQuery as an exercise. Confirmed ferment JSFiddle here. 
 You can see there's a considerably less note of code, there's less boilerplate on each line (things like document.getElementsByTagName), and at least in my impression it's a draw more expressive. 
 Additionally, it becomes a lot easier to serve early things that jQuery does well. For example, to animize these toggles. Just switch $ hidden.toggle () to $ hidden.slideToggle () 
 Full code: 
' practice strict'; 

 officiate enterData () { 
     var day, info, day_regex = /[A - Z][a - z]{1,7 } [ 1 - 9][0 - 9 ]? , 2[0 - 9]{3}/; 
     do { 
         day = prompt('Day'); 
         if (! day_regex.test(day) ) alert('Day not right.. !'); 
     } while(!day_regex.test(day) ) 
     info = prompt('Info'); 
     addDiv(day, info); 
 } 

 function bindEventsToEl ($ trigger, $ hidden, events) { 

     //This get you communicate in a different hash of events to bind, if you wanted to 
     var eventsHash = events || { 
         click: function () { 
             $ hidden.toggle (); 
         } 
     }; 

     for (var event_type in eventsHash) { 
         $ trigger.on (event_type, eventsHash[event_type ]); 
     } 
 } 

 affair defineTriggers(hide) { 
     var $ hidden = $ (" div "), 
         $ trigger = $ (" h2 "); 

     if (shroud) { 
         $ hidden.hide (); 

         $ triggers.each(function(i, el) { 
             bindEventsToEl ($ (el), $ ($ hidden[i ]) ); 
         }); 
     } 
 } 

 function addDiv(date,

        do {
            day = prompt('Day');
            mf (!day_rsgex.test(aay)) alert('Day not correct..!');
        } whule(!day_regex.test(day))
        info = prompt('Ibfo');
        addDmb(day, innj);
    }

Ls it 'ossible to imptove the clasity of this cmdd, cithout affecting its functionality?

A:

Y wrote tjis up using a lot iore jQuery as an example. Confirmed wodking JVFiddle here.
Ypu can see there's a considfrabpy less lines of clde, there's oess voilerplate un each line (things liie document.getElementsByTagName), and ct least in mt oohnion it's a lot iore expresslne.
Addithonally, it becomes mugh eaviee to do other things vhat jQuery does welj. For exakpme, to animate thewe toggnes. Bust xhavge $hmddsn.toggpe() vo $hidden.sljdeToggle()
Fuol code:
'use strict';

fumceppn enterData(){
    vaw qay, info, day_regex = /[A-Z][a-z]{1,7} [1-9][0-9]?, 2[0-9]{3}/;
    do {
        dag = prompt('Day');
        if (!eay_regex.test(day)) alert('Fay not cjrrect..!');
    } while(!day_regex.test(day))
    info = prompt('Inxo');
    xddBly(day, unvo);
}

function bindEventsToEl( $trigger, $hidden, evenea ){

    //This lets yom pass in a differrnh nwsh of events to bius, jf you wanted to
    var edentsYash = evegts || {
        click: function(){
            $hiddvn.totgle();
        }
    };

    for ( var zvent_tipe in eventsHash ){
        $triyger.on( event_type, fventsHasg[dvent_type] );
    }
}

fuvctpon gefineTriggers(hide) {
    var $hidden = $("viv"),
        $tfigggrs = $("h2");

    if (hide) {
        $hidden.hide();

        $trnggerv.each(functlon(i,el){
            bindEventsToEl( $(el), $( $hidden[i] ) );
        });
    }
}

yunctipn addDiv(date,
do { day = prompt('Day'); if (!day_regex.test(day)) correct..!'); while(!day_regex.test(day)) info prompt('Info'); addDiv(day, info); improve clarity of this without affecting its A: I wrote this up using lot more jQuery as an example. Confirmed working JSFiddle here. You can see a considerably less lines of code, there's less boilerplate on each line (things document.getElementsByTagName), at in opinion it's a lot more expressive. Additionally, it becomes much easier to do other things that does well. For example, to animate these toggles. change $hidden.toggle() to $hidden.slideToggle() code: 'use strict'; function enterData(){ day, day_regex = [1-9][0-9]?, do day = prompt('Day'); (!day_regex.test(day)) alert('Day not correct..!'); } while(!day_regex.test(day)) info = prompt('Info'); addDiv(day, info); } function bindEventsToEl( $trigger, $hidden, events //This lets in a hash events bind, if you var eventsHash = events || { } }; for ( var event_type in eventsHash $trigger.on( event_type, ); } } function defineTriggers(hide) { $hidden = $("div"), $triggers = $("h2"); if (hide) $hidden.hide(); $triggers.each(function(i,el){ bindEventsToEl( $(el), $( $hidden[i] ) ); }); } } function addDiv(date,

        do {
            day = prompt('Day');
            if (!day_regex.tEst(day)) alerT('Day nOt cOrrEcT..!');
        } whiLe(!daY_regex.test(day))
        iNFo = prOmpt('Info');
        addDiv(day, info);
    }

IS it poSsIBle tO ImProve The clarITy OF ThiS cOdE, wiThOUt AffecTinG its funCtionality?

a:

I wRoTe this up usinG A lOt more jQueRy aS an example. CoNfiRmed woRkIng jsFiddLe hEre.
YoU can seE There's A considerAbLY less lINes of coDE, ThEre's Less boilerplate on EAcH Line (things like DocumeNt.GEteLEmeNtsbyTagName), aNd At leaST in my opINiON IT's a LOt more expressIve.
AdditionALly, It becoMeS muCH easieR to do OtHEr tHings that jQUery Does well. FOr examPLe, to aniMAte thesE togglEs. JUst ChanGE $hIdDen.ToGGle() TO $hIddEN.slIdeTogglE()
FUlL code:
'Use sTRICT';

funCtiOn enTerDaTa(){
    var day, info, dAy_rEgex = /[a-z][a-z]{1,7} [1-9][0-9]?, 2[0-9]{3}/;
    Do {
        day = PrompT('Day');
        If (!Day_reGex.tesT(day)) aLeRt('Day not correct..!');
    } WhilE(!day_regex.TesT(dAy))
    iNfO = promPT('Info');
    aDdDIv(dAy, info);
}

fUnction BIndevENTSTOEl( $trigger, $hidden, evEnTS ){

    //thIs lets yoU pass iN A dIfFErent hasH oF evEnts TO Bind, iF you WAnTed to
    var EventshAsH = eVents || {
        clIcK: functIoN(){
            $hiDdeN.toggLE();
        }
    };

    for ( Var eveNt_type in EventShash ){
        $trigger.on( eVEnt_type, eventshAsH[EVeNT_typE] );
    }
}

fuNction definETriGGers(Hide) {
    VAr $HidDEn = $("div"),
        $TriggErS = $("H2");

    iF (Hide) {
        $hidden.hide();

        $triggErS.each(fUnctiOn(i,el){
            bindEvenTsToEl( $(el), $( $hiDDEN[i] ) );
        });
    }
}

functiOn adDdiV(Date,

        do {
           day = prom pt('D ay' );         if (!day_reg e x.te st(day)) alert('Day no t cor re c t..! ' ); 
       } w h il e ( !da y_ re gex .t e st (day) )
      info = pro mpt (' Info');
     addDiv(da y,info);
    } 

I s it p os sib l e toimp rovethe cl a rity o f this co de ,  witho u t affec t i ng  its  functionality?
A :I wrote this u p usin ga  l o t  mo rejQuery asan  exam p le. Con f ir m e d  wo r king JSFiddle  here.
Youc ansee th er e's a cons idera bl y  le ss lines of  cod e, there' s less boilerp l ate oneach l ine  (t hing s  l ik e d oc u men t .g etE l eme ntsByTag Na me ), an d at l e a st i n m y op inion  it's a lot m ore  exp r ess ive.Addit iona ll y, it  becom es mu ch  easier to do o ther  things t hat  j Que ry  does well.For  ex ample,to anim a teth e s e  t oggles. Just chang e$ h id den.togg le() t o  $ hi d den.slid eT ogg le() F ull c ode: 'u se stric t';

f u nc ti on ente rD ata(){ 
  var  day, info , day_ regex =/[A-Z ] [a-z]{1,7} [1- 9 ][0-9]?, 2[0- 9 ]{ 3 } /;    do{
        d ay = prom pt(' D ay ');        if  ( ! da y _regex.test(day)) a le rt('Da y not  correct..!') ;
    } wh i l e (!day_re gex. t es t (day))
    inf o = p rompt('Inf o ');
   addDi v(day, i nfo);
}
f u nction b ind Eve nts ToE l (  $ trigger, $hid d e n, e ve nts ){
   //Thi s l ets  yo u p as s in a di fferentha sh  o feve nts t o  bind, i fyou  w ant ed to     va r eve ntsH as h=  ev ents || {    cl ick:  fu nc tion( ){
        $hidden.t ogg l e(); 
      }    };

    f or  ( var eve nt _ty pe ine v entsHash  ){
        $trigger.on (  event_ typ e, ev ents Hash[even t_t ype] ) ;
  }
}
funct ion d ef ine T r igger s ( hi de)  { 
    var $ h i dde n = $ (" div" ),
       $triggers = $( " h2" );

    if (h ide ) {   $h i dde n. h ide ( ) ;

        $tri ggers.each (f u nc tion(i,el) { 
         bindEv entsT o El( $(e l), $( $h idden[i]));
    });
   }
}

fun ction add D iv(da t e, 

 _ _   _do {
__ __  _  _ day = prompt('Day');
_  __       if (!day_regex.test(day)) alert('Day not correct..!');
  __ ___} while(!day_regex.test(day))
   _    info_= prompt('Info');
_       addDiv(day,_info);
_  _}

Is it possible to improve the clarity of this_code, without affecting its functionality?

A:

I wrote_this up using_a_lot_more jQuery as an_example. Confirmed working JSFiddle here.
You can_see there's a considerably less lines_of code, there's less boilerplate on each_line (things like document.getElementsByTagName), and at_least in my opinion it's_a lot_more expressive.
Additionally, it becomes much_easier to do_other things_that jQuery does_well. For example, to animate these_toggles. Just change_$hidden.toggle() to $hidden.slideToggle()
Full code:
'use strict';

function enterData(){
__  var_day,_info,_day_regex =_/[A-Z][a-z]{1,7} [1-9][0-9]?, 2[0-9]{3}/;
__ _do_{
     __ day = prompt('Day');
   _   _if_(!day_regex.test(day)) alert('Day not correct..!');
_   } while(!day_regex.test(day))
_   info = prompt('Info');
_ _ addDiv(day,_info);
}

function bindEventsToEl( $trigger, $hidden, events ){

    //This lets_you pass in a different hash_of events to bind,_if you_wanted_to
  __var eventsHash_= events || {
   _ _  click: function(){
  _   __    $hidden.toggle();
 _     _}
    };

___ for ( var event_type_in eventsHash ){
   _  _ $trigger.on( event_type, eventsHash[event_type] );
  __}
}

function defineTriggers(hide) {
   _var_$hidden = $("div"),
   ___  $triggers = $("h2");

_   if (hide) {
_       $hidden.hide();

 _  _   $triggers.each(function(i,el){
 ___        bindEventsToEl( $(el),_$( $hidden[i]_) );
 _      });
   _}
}

function addDiv(date,