PDA

View Full Version : how to create a python dictionary in JavaScript



ann.onimus07
04 Apr 2012, 09:07 AM
I have this Python code:


Hanzi ={'我':'wo3','你':'ni3','他':'ta1'}#this is the dictionary

randHanzi=random.choice(list(Hanzi))
print(randHanzi)

userInput=input()

if (userInput,randHanzi) in Hanzi.items():
print('Yes!')
elif (userInput,randHanzi) not in Hanzi.items():
print('No!')

This code randomly prints the first value from Hanzi dictionary and then gets input from user and evaluates.

How to do this in JavaScript???