Nagarro Interview Question

How to swap two words in a given string?

Interview Answers

Anonymous

Jun 20, 2022

(((string.split(' ')).reverse()).toString()).replace(',',' ' ');

Anonymous

Jun 20, 2022

var string='test world'; (((string.split(' ')).reverse()).toString()).replace(',',' ');