console.assert(condition, message) Last updated: 22. May 2023
This function checks if a certain condition is false. If it is, outputs an error message and throws an exception with the message.
Parameters
Name | Type | Description |
---|---|---|
condition | bool | |
message | string |
Returns
Null if condition is true, throws an exception if it is false with the specified message as error message.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// Testing addition and multiplication
let result = 2 + 3 * 4;
console.assert(result === 14, `Expected 14, but got ${result}`);