triko
11-09-2012, 04:37 PM
This program Calculate the TAX CODE! If the name have less than 3 consonants, is insert the first vocal at the end of 2 consonants; EXAMPLE:
1° case
LUCA ==> L, C, U
ANNE ==> N, N, A
BELA ==> B, L, E
If the name have more of 3 consonants, I take first, and second jump, and I take third and fourth consonants EX:
2° case
ALEXANDER ==> L, N, D
JONATHAN ==> J, T, H
SANDRO ==> S, D, R
3° case
If the name have less to 3 letters, I add X at the end of word
RA ==> RAX
AS ==> ASX
Ok now that i have explained how to work Tax Code, I have a problem; I don't know how to count the consonants in the name EX: LUCA, for insert the "U" at the end of consonants!!!
I say " It's possible insert a VARiable = 0 into the cycle FOR that increases with each consonants, that at the end I have a VAR with a value < 3 or > 3, for continue and create 1°, 2°, and 3° case???"
Thanks you all for your Time and Attention :D
This is code
function calculateName(name)
{
var myName = "";
for (var i = 0; i < name.length; i++)
{
var count = 0;
if ( (name[i] != "a") && (name[i] != "e") && (name[i] != "i") && (name[i] != "o") && (name[i] != "u") )
{
var myName;
myName = myName + name[i];
myName = myName.substring (0,3);
count ++;
}
}
alert (myName);
alert (count);
}
1° case
LUCA ==> L, C, U
ANNE ==> N, N, A
BELA ==> B, L, E
If the name have more of 3 consonants, I take first, and second jump, and I take third and fourth consonants EX:
2° case
ALEXANDER ==> L, N, D
JONATHAN ==> J, T, H
SANDRO ==> S, D, R
3° case
If the name have less to 3 letters, I add X at the end of word
RA ==> RAX
AS ==> ASX
Ok now that i have explained how to work Tax Code, I have a problem; I don't know how to count the consonants in the name EX: LUCA, for insert the "U" at the end of consonants!!!
I say " It's possible insert a VARiable = 0 into the cycle FOR that increases with each consonants, that at the end I have a VAR with a value < 3 or > 3, for continue and create 1°, 2°, and 3° case???"
Thanks you all for your Time and Attention :D
This is code
function calculateName(name)
{
var myName = "";
for (var i = 0; i < name.length; i++)
{
var count = 0;
if ( (name[i] != "a") && (name[i] != "e") && (name[i] != "i") && (name[i] != "o") && (name[i] != "u") )
{
var myName;
myName = myName + name[i];
myName = myName.substring (0,3);
count ++;
}
}
alert (myName);
alert (count);
}