0
var obj = {"":"empty string", "!":"bang", "hello world":"hello world"}

-Fix these lines of code so it works?

Whatever method i've tried, i keep coming up with an undefined property name for "" or an error when calling for !.

I'm very new to coding and am not looking for an answer, maybe just a push in the right direction..So please be gentle and thanks for any help

TaoPR
  • 5,932
  • 3
  • 25
  • 35
  • 2
    possible duplicate of [Getting the value of an object's property where the key is a blank string](http://stackoverflow.com/questions/13848798/getting-the-value-of-an-objects-property-where-the-key-is-a-blank-string) – use the same technique to get the one with the exclamation mark. – JJJ Aug 07 '15 at 18:21

2 Answers2

2

You must call obj like an Array

console.log( obj [''] ); // "empty string"
console.log( obj ['!'] ); // "bang"
var x='!';
console.log( obj [x] ); // "bang"
Emilio Platzer
  • 2,327
  • 21
  • 29
0

As per my understanding you want to retrieve "Empty String"

You can get the information by following

var obj = {"":"empty string", "!":"bang", "hello world":"hello world"}

console.log(obj[""]);
Nikhil Aggarwal
  • 28,197
  • 4
  • 43
  • 59