wantToAsk,
<script>
function stringToArray(line) {
let arrayOfSymbols = [",", ".", "!", "?"];
let item = "";
let arrOfWords = [];
a: for (let i = 0; i < line.length; i++) {
let symbol = line[i]
if (symbol === " ") continue a;
for (let k = 0; k < arrayOfSymbols.length; k++) {
if (arrayOfSymbols[k] == symbol) {
if (item) {
arrOfWords.push(item);
item = "";
};
arrOfWords.push(symbol);
continue a
}
}
item += symbol;
}
if (item) arrOfWords.push(item);
return arrOfWords
}
let ar = stringToArray('Hello, world!');
document.write(JSON.stringify(ar, "", 4))
</script>