function validateFirst(input) 219 { 220 let result = false; 221 //Value and position 222 let first = []; 223 console.log("Parsing string '" + input + "'"); 224 for (let i = 0; i < input.length; ++i) 225 { 226 let tmp = parseInt(input[i]); 227 if (!isNaN(tmp)) 228 { 229 console.log(input[i] + ": Is a number"); 230 if (first[0] && (tmp + first[0] === 10)) 231 { 232 console.log("first is not empty and tmp + first === 10 (" + tmp + " + " + first[0] + " === " + (tmp + first[0])); 233 console.log("Finding questions..."); 234 //Iterate backwards to see how many question marks exist between the pair 235 let questions = 0; 236 for (let j = i; j > first[1]; --j) 237 { 238 if (input[j] === '?') 239 { 240 ++questions; 241 console.log(input[j] + ": Is a question. question total is now " + questions); 242 } 243 else 244 { 245 console.log(input[j] + ": Is not a question."); 246 } 247 } 248 if (questions === 3) 249 { 250 console.log("questions === 3! result is now true."); 251 result = true; 252 } 253 else 254 { 255 console.log("questions !== 3. result is false and breaking."); 256 result = false; 257 break; 258 } 259 } 260 first[0] = tmp; 261 first[1] = i; 262 } 263 else 264 { 265 console.log(input[i] + ": Is not a number"); 266 } 267 } 268 return result; 269 }