One More Time - Simplicity Winner


Start with breaking the given songs into words and stanza's and then use it wherever is needed. Firstly assign all the repeated words to a variables

var nl = "&nbsp;<br>";
var omt = "One more time<br>";
var wgc = "We're gonna celebrate<br>";
var oy = "Oh yeah<br>";
var dsd = "Don't stop the dancing<br>";
var mgff = "Music's got me feeling so free<br>";
var cdf = "Celebrate and dance so free<br>";

Create stanza's as much as possible to avoid the repeated use of variables/words

var stanza1 = omt + wgc + "Oh yeah, all right<br>" + dsd;
var stanza4 = omt + mgff + wgc + cdf;
var stanza2 = "Mmm, you know I'm just feeling<br>Celebration tonight<br>Celebrate<br>Don't wait too late<br>Mmm, no<br>We don't stop<br>You can't stop<br>"+wgc;
var stanza3= "Celebration<br>You know we're gonna do it right, tonight<br>Hey! Just feeling<br>Music's got me feeling the need<br>Need, yeah<br>Come on, all right<br>"+wgc;

Create possible groups to reduce the line of code and make efficiency

First group: In this example I have grouped below lines in one loop.

One more time
Celebrate and dance so free
Music's got me feeling so free
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free
One more time
Music's got me feeling so free
We're gonna celebrate
Celebrate and dance so free

Below is the logic for the above line of text:

for(j=1;j<16;j++)
{
Write(stanza4);
if(j==5)
Write(nl);
if(j==9)
Write(omt + mgff + wgc);
if(j==11)
Write(nl);
}

Wherever we need a newline or additional words add the condition to apply on that step inside the loop instead of breaking the loop.

Second group:

One more time
We're gonna celebrate
Oh yeah, all right
Don't stop the dancing
One more time
We're gonna celebrate
Oh yeah, all right
Don't stop the dancing
One more time
We're gonna celebrate
Oh yeah, all right
Don't stop the dancing
One more time
We're gonna celebrate
Oh yeah
One more time
One more time
We're gonna celebrate
Oh yeah, all right
Don't stop the dancing

Below is the logic for the above line if text:

for(j=1;j<6;j++)
if(j==4)
Write(omt + wgc + oy+omt+nl);
else
Write(stanza1);

In last combine all in one single group.

<script runat="server" language="javascript">
   Platform.Load("Core","1");
   //Assign the repeated words to a variables
   var nl = "&nbsp;<br>";
   var omt = "One more time<br>";
   var wgc = "We're gonna celebrate<br>";
   var oy = "Oh yeah<br>";
   var dsd = "Don't stop the dancing<br>";
   var mgff = "Music's got me feeling so free<br>";
   var cdf = "Celebrate and dance so free<br>";
   //create stanza's as much as possible to avoid the repeated use
   var stanza1 = omt + wgc + "Oh yeah, all right<br>" + dsd;
   var stanza4 = omt + mgff + wgc + cdf;
   var stanza2 = "Mmm, you know I'm just feeling<br>Celebration tonight<br>Celebrate<br>Don't wait too late<br>Mmm, no<br>We don't stop<br>You can't stop<br>"+wgc;
   var stanza3= "Celebration<br>You know we're gonna do it right, tonight<br>Hey! Just feeling<br>Music's got me feeling the need<br>Need, yeah<br>Come on, all right<br>"+wgc;
   //Wherever possible create loop/condition statement to avoid unnecessary usage of codes 
   for (i=1;i<7;i++)
   {
    Write(omt);
    if (i==2)
    {
     Write(nl);
     for(j=1;j<6;j++)
      if(j==4)
       Write(omt + wgc + oy+omt+nl);
      else
       Write(stanza1);
     Write(omt + wgc + oy + dsd + omt+nl+stanza2);
    }
    if (i==5)
     Write(stanza3);
    if (i==6)
    {
     Write(cdf+mgff+cdf);
     for(j=1;j<16;j++)
     {
      Write(stanza4);
      if(j==5)
      Write(nl);
      if(j==9)
      Write(omt + mgff + wgc);
      if(j==11)
      Write(nl);
     }
    } 
   }
</script>
All Rights Reserved
Made with by your fellow SFMC users.
All Rights Reserved
Made with by your fellow SFMC users.