Category: Variables
Displays a string and/or variable values in the debug console in App Lab.
console.log() is used as a debugging tool to help you understand what your code is doing. By displaying a message containing either descriptive text that tells you what is happening or the value of particular variables, you can follow along as your code executes. The user of your app will not see the console.log() messages.
// Let's you know your code is running. console.log("It's Alive!");
Example: Random Thought I'm thinking of a number between 1 and 10.
// I'm thinking of a number between 1 and 10. var myRandomNumber = randomNumber(1,10); console.log("My random number is: " + myRandomNumber);
Example: Checkbox Value Display the true/false state of a checkbox.
// Display the true/false state of a checkbox. checkbox("myCheckbox", false); textLabel("myLabel", "Click on or off", "myCheckbox"); onEvent("myCheckbox", "click", function(event) { console.log("Checkbox is: " + getChecked("myCheckbox")); });
console.log(message)
Name | Type | Required? | Description |
---|---|---|---|
message | string | Yes | The message string and/or variable values to display in the console. |
No return value. Outputs to the console only.
Found a bug in the documentation? Let us know at documentation@code.org
Found a bug in the documentation? Let us know at documentation@code.org