Map Symbols | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Map Symbols

function mapSymbols(N) { let alpha="!@#$%^&*"; let obj = {}; for(i=0;i<alpha.length;i++){ let chr = alpha[i]; obj[chr]=i+N; } for(let key in obj){ console.log(`${key}-${obj[key]}`); } } input = 20 desire output = !-20 @-22 #-24 $-26 %-28 ^-30 &-32 *-34 what i get !-20 @-21 #-22 $-23 %-24 ^-25 &-26 *-27 i don't understand how to increase my key value by 2 for every key

3rd Jun 2022, 5:03 PM
TINKLE DASH
TINKLE DASH - avatar
2 Answers
0
Jay Matthews if I increase the I value it going to effect my key of the object also because it also increase with the I value
3rd Jun 2022, 5:45 PM
TINKLE DASH
TINKLE DASH - avatar
0
Yes that's r8 Jay Matthews 😊 Basically I also solve it But I increase the value of N by 2 And then obj[chr]=I+N-2 But your ans more understandable
3rd Jun 2022, 6:06 PM
TINKLE DASH
TINKLE DASH - avatar