let PlayerData = {
    Travis: {
      keyboard: "ojnfijoewf",
      mouse: "wefewf",
      monitor: "kfmwefwe",
      sens: ["dpi","ingamesens"],
      controller: "xbox",
      ping: 120,
      biography: "was born in",
      earnings: 23455,
      resolution: "1920 x 1080",
      social_media: ["Youtube","Twitter"],
      debut: "Desember",
      signed: ["Free-Agent",""]
    }
  }
  
$(function(){
    $('#search-button').on('click', function() {
        var player_name = $('#player-search').val();
    
        $("#card-player-title").html(PlayerData.player_name);
        $(".card-text").html(PlayerData.player_name.biography);
    })
});
            Asked
            
        
        
            Active
            
        
            Viewed 81 times
        
    0
            
            
         
    
    
        Imran Rafiq Rather
        
- 7,677
- 1
- 16
- 35
 
    
    
        Milahn
        
- 21
- 3
1 Answers
1
            
            
        You can't use dot notation with dynamic keys. JavaScript will return you the property called player_name literally, which doesn't exist, that's why you get undefined. Use [], like this:
var player_name = $('#player-search').val();
$("#card-player-title").html(PlayerData[player_name]);
$(".card-text").html(PlayerData[player_name].biography);
 
    
    
        Álvaro Tihanyi
        
- 1,062
- 1
- 11
- 18
- 
                    Yess ty very much my friend really appreciate it <3 Merry Christmas to you <3 – Milahn Dec 25 '20 at 13:16
- 
                    You're welcome, and Merry Christmas! – Álvaro Tihanyi Dec 25 '20 at 13:17