I want to take a string, and change each character. I.e. A becomes E or F becomes C.
what I have is this:
function convert(){
var text=document.getElementById('textInp').value;
alert(text);
for()
}
I don’t know what to do in the for loop
I want to take a string, and change each character. I.e. A becomes E or F becomes C.
what I have is this:
function convert(){
var text=document.getElementById('textInp').value;
alert(text);
for()
}
I don’t know what to do in the for loop
use
string
length and iterate and replace whatever you want.Try this
split("")
split the string with space .and match the letter then replace using mapYou can split and join your String
There is a direct option to iterate over a string directly: to use
for...of
orfor...in
:You can iterate over each of the characters in the text like this