i have a really strange problem in java script. look at these codes and run the app:
const number = 200000;
const persianMoney = "تومان";
//pay attention to these lines:
console.log("way 1:");
console.log(number + persianMoney);
console.log(persianMoney + number);
console.log("way 2:");
console.log(`${number}${persianMoney}`);
console.log(`${persianMoney}${number}`);
console.log("way 3:");
console.log(String(number) + persianMoney);
console.log(persianMoney + String(number));
console.log("way 4:");
console.log(`${String(number)}${persianMoney}`);
console.log(`${persianMoney}${String(number)}`);
console.log("way 5:");
console.log(String(number + persianMoney));
console.log(String(persianMoney + number));
all of the outputs are the same!! all of the outputs are 200000تومان
! but why word تومان
is not behind 200000
in some outputs? even here, i cant put تومان
behind 200000
! but why it is like that? i cant understand it. i tested concatenation in 5 ways but none of them were correct! how can i solve this problem? thanks for helping.
As stated by Raymand Chen. My understanding is that you want to have the currency name تومان after the number 200000. To keep the Arabic/Persian word in the same direction as the Latin word i.e. in a Left-To-Right LTR direction.
One possible way to do that is to add the LTR code \u200E
const number = 200000;
const persianMoney = "تومان";
const ltr = "\u200E";
console.log(persianMoney + ltr + " " + number);