converting a string in an array code example
Example 1: convert string to array js
let string = 'ABCDEFG';
let newArray = string.split('');
console.log(newArray);
Example 2: how to convert string to array in java
How to convert string to array
import java.util.*;
public class GFG {
public static void main(String args[])
{
String str = "GeeksForGeeks";
char[] ch = str.toCharArray();
for (char c : ch) {
System.out.println(c);
}
}
}
Example 3: turn array into string
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));