I want to convert string to bytes it worked fine if i assign value to var str as $scope.event[0] it gives me bytes only for first index ,if i  assign $scope.event[] it hrows error str.charCodeAt is not a function. How can i get total bytes of the array ?  
ctrl.js
    $scope.event = ["lorem ipsum", "lorem ipsum","lorem ipsum"]
     function jsonToArray() {
            var total = 0;
            var str = $scope.event;
            var bytes = []; // char codes
            var bytesv2 = []; // char codes
            for (var i = 0; i < str.length; ++i) {
                var code = str.charCodeAt(i);
                bytes = bytes.concat([code]);
                bytesv2 = bytesv2.concat([code & 0xff, code / 256 >>> 0]);
            }
            var totalBytes = 0;
            console.log('bytes', bytes.join(', '));
            for ( var i = 0 ; i < bytes.length ; i++ ) {
                totalBytes += bytes[i];
                totalCurrentBytes.push(totalBytes);
            }
            console.log('Total bytes', totalBytes);
            formatBytes(totalBytes);
        }
  jsonToArray();
 
    