js/game.js
//create all necessary JS objects and write the message in blank letters on the heads-up-display
create all necessary JS objects and write the message in blank letters on the heads-up-display
create all necessary JS objects and write the message in blank letters on the heads - up - display
function writeMessage(){
    for (var i=0, len=message.length; i<len; i++){
      if (message.charAt(i) === ' '){
        messageHTML += '<div class=\"item space\"><div class=\"item-letter\">&nbsp;<\/div><\/div>';
      }
      else {
        messageHTML += '<div class=\"item\"><div class=\"item-letter\">'+message.charAt(i)+'<\/div><\/div>';
        if (objects[0]!= undefined){
          objectsLength = objects.length;
        }
        else {
          objectsLength = 1;
        }
        for (var j=0, length=objectsLength; j<length; j++){
          if (objects[0]!= undefined){
            if ( objects[j].name == message.charAt(i) ){
              alreadyExists = true;
            }
          }
          if (j >= (length - 1) && alreadyExists == false ){
            objects.push(new Object('letter',message.charAt(i)));
          }
        }
        alreadyExists = false;
      }
      if (i == (len - 1)){
        $('#item-container').append(messageHTML);
      }
    }
  }
function writeMessage ( ) { for ( var i = 0 , len = message . length ; i < len ; i ++ ) { if ( message . charAt ( i ) === ' ' ) { messageHTML += '<div class=\"item space\"><div class=\"item-letter\">&nbsp;<\/div><\/div>' ; } else { messageHTML += '<div class=\"item\"><div class=\"item-letter\">' + message . charAt ( i ) + '<\/div><\/div>' ; if ( objects [ 0 ] != undefined ) { objectsLength = objects . length ; } else { objectsLength = 1 ; } for ( var j = 0 , length = objectsLength ; j < length ; j ++ ) { if ( objects [ 0 ] != undefined ) { if ( objects [ j ] . name == message . charAt ( i ) ) { alreadyExists = true ; } } if ( j >= ( length - 1 ) && alreadyExists == false ) { objects . push ( new Object ( 'letter' , message . charAt ( i ) ) ) ; } } alreadyExists = false ; } if ( i == ( len - 1 ) ) { $ ( '#item-container' ) . append ( messageHTML ) ; } } }
create all necessary JS objects and write the message in blank letters on the heads-up-display
create all necessary JS objects and write the message in blank letters on the heads - up - display
//iterate through the letters in the message variable //create objects for letters that don't yet exist //iterate through objects that have been created to detect whether they've been created already //if array has an item //detect whether the object of this letter has been created already //console.log('letter found'); // add the letter if it doesn't already exist //console.log('letter object created'); //reset //output the HTML