code example: def stuff do
As we get into testing, I looked up console.assert(), which was in the google sample code in the above link (popup.js). It’s a way to run an inline test. If the assertion is false, it logs the passed error message, if true it does nothing.
For example :
var imageUrl = “http://something.com"; var width = “two hundred"; var height = 300; console.assert( typeof imageUrl == 'string' && !isNaN(width) && !isNaN(height), 'Unexpected respose from the Google Image Search API!’);
Would log an error because of the width variable.