settingsAccountsettings
Menusettings

Q: Concatenate Reversed - JavaScript Task

+2 votes

Write a JavaScript function that reverses a series of strings and prints them concatenated from last to first. The input comes as an array of strings.

Examples:

Input:
['I', 'am', 'student']

Output:
tnedutsmaI


Input:
['race', 'car']

Output:
racecar


The output is printed on the console. Print all strings concatenated on a single line, starting from the last input string, going to the first. Reverse each individual string’s letters.

asked in JavaScript category by user golearnweb

2 Answers

+1 vote

MY js code:

function conRev(arrStr){
    let s = arrStr.join("");
    let chars = Array.from(s);
    let revChars = chars.reverse();
    let revStr = revChars.join("");

    let result="";
    for (let i in revStr) {
        result+=`${revStr[i]}`;
    }
    console.log(result);
}

conRev(['I', 'am', 'student']);

 

answered by user richard8502
0 votes

My javascript code:

function solve(arrS){
    let s = arrS.join("");
    let chars = Array.from(s);
    let reverseChars = chars.reverse();
    let revString = reverseChars.join("");
    console.log(revString);
}

solve(['I', 'am', 'student']);

 

answered by user eiorgert
function cr(input) {

    let string = String(input);
    let o = '';
    for (let i = string.length - 1; i >= 0; i--) {
        o += string[i];
    }
    o = o.split(',').join('');
    console.log(o);
}
...