Jump to content

SparX

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by SparX

  1. Hello everyone! I need someone to tell me what's wrong with this script:

    function stringToArray(string){
    			var sVector = [string.split];
    			var iR;
    
    			for (i=0;i<=sVector.length;i++)
    				iR = sVector;
    			
    			return iR;
    
    		}
    
    
    		function stringEncode(string){
    			var vector = string.split("");
    			var iR;
    			for (i=0;i<=string.length;i++){
    				iR += string.charCodeAt(i);
    			
    
    			}return iR;
    		}
    
    
    			window.onload = function (){
    				document.getElementById('clickButton').onclick = function(){
    					alert(stringEncode(document.getElementById('textEr').value));
    				}
    			}
    

    I try to define a function that encodes a simple string, but it returns "NaN" instead of numbers.

    Thanks in advance.

×
×
  • Create New...