⭐How to change variable name dynamically? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

⭐How to change variable name dynamically?

Example: words = {Apple, Avocado}; // will be different, different amount, i will not know them array = {}; array.fruitApple = 5; array.fruitAvocado = 20; console.log(array); I need add to array keys that starts with "fruit" and ends with different words from "words". And then output in console.

28th Jan 2023, 8:37 PM
PR PRGR
PR PRGR - avatar
2 Answers
0
Mirielle Thank you very very much!!!🤗
28th Jan 2023, 8:56 PM
PR PRGR
PR PRGR - avatar
0
You cannot do this. However : 1.You can assign a new value. 2 Nullify it 3.Garbage collect it.
30th Jan 2023, 7:15 AM
Sanjay Kamath
Sanjay Kamath - avatar