for element in string js code example Example: for element in string js for (var i = 0; i < str.length; i++) { alert(str.charAt(i)); }