diff --git a/index.html b/index.html new file mode 100644 index 0000000..8041e23 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..186197e --- /dev/null +++ b/main.js @@ -0,0 +1,32 @@ +function stringScore(word) { + var total = 0; + var one = 0, two = 0, three = 0, four = 0, five = 0, eight = 0, ten = 0; + for (var i = 0; i < word.length; i++) { + if (word[i] == 'a' || word[i] == 'e' || word[i] == 'i' || word[i] == 'o' + || word[i] == 'u' || word[i] == 'l' || word[i] == 'n' || word[i] == 'r' + || word[i] == 's' || word[i] == 't') { + one = one + 1; + } + else if (word[i] == 'd' || word[i] == 'g') { + two = two + 2; + } + else if (word[i] == 'b' || word[i] == 'c' || word[i] == 'm' || word[i] == 'p') { + three = three + 3; + } + else if (word[i] == 'f' || word[i] == 'h' || word[i] == 'v' || word[i] == 'w' || word[i] == 'y') { + four = four + 4; + } + else if (word[i] == 'k') { + five = five + 5; + } + else if (word[i] == 'j' || word[i] == 'x') { + eight = eight + 8; + } + else if (word[i] == 'q' || word[i] == 'z') { + ten = ten + 10; + } + } + total = one + two + three + four + five + eight + ten; + return total; +} +console.log(stringScore("cabbage")); diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..1b83581 --- /dev/null +++ b/main.ts @@ -0,0 +1,36 @@ +function stringScore(word: string): number{ + var total =0; + var one=0,two=0,three=0,four=0,five=0,eight=0,ten=0; + for(var i=0;i