Need help with basics: switch structure/repetition

Discussion in 'Java Script/AJAX' started by Indianseo, Jul 19, 2010.

Remove these ads by signing in
Remove these ads by signing in
  1. Indianseo Banned

    Member Since:
    Jul 15, 2010
    Message Count:
    30
    Likes Received:
    0
    Hi Friends

    college student here having some trouble with the JavaScript portion of my computer science class. I'm almost done with this week's assignment, but this one problem is giving me fits.

    It asks me to wite a script that uses repetition and a switch structure to print the song 'The Twelve Days of Christmas.'

    I somewhat understand what it is trying to get me to do... something along the lines of, case "1": A partridge in a pear tree. case "2": case "1" + two turtle doves...



    And I also know that I should probably make a variable for each "day".. I just can't wrap my head around the problem as a whole. Please help me. I'm not some lazy student on here begging yall to do my homework, I just can't get help from my professor since the class is being taken in and online format and can't afford a tutor! I've worked hard on this and hate to hit this wall.


    Thanks In advance:)
  2. PradeepKr New Member

    Member Since:
    Aug 16, 2010
    Message Count:
    22
    Likes Received:
    0
    I was totally clueless to what you were asking then It clicked. You should have pasted the lyrics of the song here.

    See, On the first day there are 3 lines and on successive days the number of line is increasing 1 per day.
    The text in the lines is almost same on each day which can be hard-coded.
    So put these harcoded text in switch and manage "break" based on the day number. Put switch in the nested loop.
  3. markhill New Member

    Member Since:
    Mar 31, 2010
    Message Count:
    41
    Likes Received:
    0
    Give me the lyrics then will be able to give you whole process.

Share This Page