1// Define the string
2var string = 'Hello World!';
3
4// Encode the String
5var encodedString = btoa(string);
6console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh"
7
8// Decode the String
9var decodedString = atob(encodedString);
10console.log(decodedString); // Outputs: "Hello World!"