How to reverse string using next conditions:
1) if string isn't parameter of function,
2) if string is place in global scope,
3) use loop like for, while,
4) can add one variable
Note: Can't use method .join, .split, .reverse and so on...
If it possible and not so hard for you make explain your solution, very grateful !
In other words, this is what you got:
let s = 'any string';
let p; // feel free to use at your discretion
// your code here. No further variables, no functions and no built-ins
// should console.log the reversed string
I'm understand that my solution is very close to my desire (conditions), but i can't generate other solution.
function convers(s){ //parameter
var str = "";//empty string for new converted string
for(var i = s.length-1; i >= 0; i--)//loop decremebtation that count from end of string
str+=s[i];//store result and assignments to str
return str;// declare result
}
console.log(convers("abcdef"));
I looked this source: javascript reverse string algorithm
Is there a faster Reverse String Algorithm for JavaScript? - but it is useless for me, sorry.
I'm sorry if my explanation is not clear enough. Sorry for my English, I'm beginner here :))))