@@ -37,7 +37,7 @@ function initialPrompt() {
37
37
return info ;
38
38
} ;
39
39
40
- let newPointStructure ;
40
+ let newPointStructure = { } ; //TODO: make this an object of 26 letter keys and the values consistent with the points from the oldPointStructure
41
41
42
42
let simpleScorer = function ( word ) {
43
43
word = word . toUpperCase ( ) ;
@@ -94,18 +94,38 @@ function scorerPrompt() {
94
94
}
95
95
return scoringAlgorithms [ scorerProgramIndex ] . scorerFunction ;
96
96
} ;
97
- // create an array with the scorer functions, from the user input, call the relavant algorithym and print the word and score
98
97
99
- function transform ( ) { } ;
98
+ function transform ( oldPointStructureObject ) {
99
+ let newPointStructureObject = { } ;
100
+ // loop through object
101
+
102
+ for ( let item in oldPointStructureObject ) {
103
+ // data variables need for new object
104
+ let currentObject = oldPointStructureObject [ item ] ;
105
+ let newKey = currentObject . type . toLowerCase ( ) ;
106
+ let newValue = currentObject . item . toLowerCase ( ) ;
107
+
108
+ // add these to new object key:value pair
109
+ newPointStructureObject [ newKey ] = newValue ;
110
+
111
+ }
112
+ return newPointStructureObject ;
113
+ } ;
114
+ console . log ( "Letters with score '4':" , oldPointStructure [ 4 ] ) ;
115
+ console . log ( "3rd letter within the key '4' array:" , oldPointStructure [ 4 ] [ 2 ] ) ;
116
+
117
+ let letters = oldPointStructure [ 8 ] ;
118
+ console . log ( "Letters with score '8':" , letters ) ;
119
+ console . log ( "2nd letter within the key '8' array:" , letters [ 1 ] ) ;
100
120
101
121
function runProgram ( ) {
102
122
let wordInput = initialPrompt ( ) ;
103
123
let scorerFunction = scorerPrompt ( ) ;
104
124
let score = scorerFunction ( wordInput ) ;
105
- console . log ( `Score for'${ wordInput } ': ${ score } ` ) ;
125
+ // let transformOldToNew = transform(oldPointStructure);
126
+ console . log ( `Score for '${ wordInput } ': ${ score } ` ) ;
127
+
106
128
}
107
- // console.log("algorithym name: ", scoringAlgorithms[2].name);
108
- // console.log("scorerFunction result: ", scoringAlgorithms[2].scorerFunction('JavaScript'));
109
129
110
130
// Don't write any code below this line //
111
131
// And don't change these or your program will not run as expected //
0 commit comments