 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Reversing a string using for loop in JavaScript
We are required to write a JavaScript function that takes in a string as the only argument. The function should construct a new reversed string based on the input string using the for a loop.
Example
Following is the code −
const str = 'this is the original string'; const reverseString = (str = '') => {    let reverse = '';    const { length: len } = str;    for(let i = len - 1; i >= 0; i--){       reverse += str[i];    };    return reverse; }; console.log(reverseString(str));  Output
Following is the output on console −
gnirts lanigiro eht si siht
Advertisements
 