Hi Student,
Your problem is one of scope. The question you have to answer is what is the value of btnNum when the onclick function is called.
Consider the following example:
var foo;| var testArray1 = [1, 0, -1]; // expected [-1, 1] | |
| var testArray2 = [1, 1, 1, 1, 1, 1]; // expected [1, 1] | |
| var testArray3 = []; //expected [] | |
| function getBounds ( intArray ) { | |
| var MIN_INT; | |
| var MAX_INT; | |
| if ( intArray.length <= 0 ) return []; |
| "use strict"; | |
| /* | |
| * Challenge: | |
| * You are given a function 'secret()' that accepts a single integer parameter | |
| * and returns an integer. In your favorite programming language, write a | |
| * command-line program that takes one command-line argument (a number) and | |
| * determines if the secret() function is additive | |
| * [secret(x+y) = secret(x) + secret(y)], for all combinations x and y, where x | |
| * and y are all prime numbers less than the number passed via the command-line |
| $ npm install | |
| npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible. | |
| npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible. | |
| npm WARN prefer global [email protected] should be installed with -g | |
| > [email protected] install /Users/jacob_lamont/Quietyme/Website/frontend/node_modules/react-grid-layout/node_modules/git-validate | |
| > node bin/install | |
| > [email protected] install /Users/jacob_lamont/Quietyme/Website/frontend/node_modules/react-grid-layout/node_modules/fsevents |
| window.console.log = function ( output ) { | |
| if ( typeof output == "Array" || typeof output === "Object" ) | |
| output = JSON.stringify( output, null, 2 ); | |
| document.getElementById( "console" ).innerHTML += output + "\n"; | |
| }; |