The error occurs between lines 38 and 39, inside the if statement (according to the Chrome JS Console. I assume that means my error is on line 39). I don’t know what I’m doing wrong, if anyone can help me that would be awesome. Thanks. If you want to see the code before I broke it, this app is running live at http://piratena.me/
/*This object is a simple dictionary that matches every letter of the alphabet to a pirate-related string.*/
var altDictionary = {
a: 'arr',
b: 'pegleg',
c: 'timber',
d: 'monkey',
e: 'knife',
f: 'powder',
g: 'grog',
h: 'scuttle',
i: 'keel',
j: 'cannon',
k: 'sparrow',
l: 'cutlass',
m: 'mast',
n: 'plank',
o: 'matey',
p: 'bag',
q: 'doubloon',
r: 'rope',
s: 'rum',
t: 'chip',
u: 'lubber',
v: 'spit',
w: 'patch',
x: 'salt',
y: 'tack',
z: 'tortuga'
}
/*This function loops through the input from the user, replacing each letter in their name with a pirate-related string.*/
var altName = function(name) {
var result = "";
for (i=0; i<name.length; i++) {
var ind=name[i];
if isAlpha(ind) === true {
ind = toLowerCase(ind);
var syl = altDictionary[ind];
result = result + syl + "-";
} else {
alert("Your name can only contain alphabetical letters.");
}
}
result = result.substring(0, result.length - 1)
return result;
};
/*This block of jQuery inserts the newly created Pirate Name into the output field*/
$(document).ready(function() {
$('form #click_button').click(function(event) {
event.preventDefault();
var name = $('#input_box').val();
$('#output p').text(altName(name));
});
});
The first thing I notice is this:
Why no parenthesis?
By the way, it doesn’t help to suggest for us to go to your live example to find out that you have different code running than what you supplied in your question.