Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.


String.localeCompare Example

node v8.11.4
version: 2.0.0
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare function areEqualIgnoreCase(str1, str2) { if (!str1 || !str2) { return false; } const result = str1.localeCompare(str2, undefined, { sensitivity: 'base' }); return (result === 0); } function runTestCase(str1, str2) { const areEqual = areEqualIgnoreCase(str1, str2); console.log(`Are ${str1} and ${str2} equal (ignoring case)? ${areEqual}`); } runTestCase('foo', 'bar'); runTestCase('foo', 'foo'); runTestCase('foo', 'FoO'); runTestCase('bar', 'BAR');

no comments

    sign in to comment