0

I want to use a simple substitution code, with (perhaps) a dictionary. In Python, it's straightforward but I want to write it in JavaScript.

dict = {}
dict["c"]="f"
dict["u"]="i"
dict["t"]="j" .... 

for x in message:
    print (dict[x].upper())
ekhumoro
  • 115,249
  • 20
  • 229
  • 336
  • 2
    Are you confused on how to make a dictionary? https://stackoverflow.com/questions/7196212/how-to-create-dictionary-and-add-key-value-pairs-dynamically Your question isn't very specific with the code sample. – Jay Mason Jan 07 '19 at 18:19
  • You can just create an object for this job. Javascript objects are like python dictionaries in that you can use string as key and retrieve a value. – Kevin He Jan 07 '19 at 18:43

1 Answers1

0

let dict = {}
dict["c"]="f"
dict["u"]="i"
dict["t"]="j"

for(let key in dict){
  console.log(dict[key].toUpperCase())
}
Code Maniac
  • 37,143
  • 5
  • 39
  • 60