From 3cf11891e53f8f63c4a566f66f122a4dff8e0c6d Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Fri, 1 Sep 2017 12:07:53 -0500 Subject: [PATCH] Add basic es6 --- es6/default-parameters.js | 0 es6/ends-with.js | 9 +++++++++ es6/includes.js | 9 +++++++++ es6/starts-with.js | 9 +++++++++ 4 files changed, 27 insertions(+) create mode 100644 es6/default-parameters.js create mode 100755 es6/ends-with.js create mode 100755 es6/includes.js create mode 100755 es6/starts-with.js diff --git a/es6/default-parameters.js b/es6/default-parameters.js new file mode 100644 index 0000000..e69de29 diff --git a/es6/ends-with.js b/es6/ends-with.js new file mode 100755 index 0000000..818079a --- /dev/null +++ b/es6/ends-with.js @@ -0,0 +1,9 @@ +'use strict'; + +let strToSearch = 'a-really-long-hyphenated-string'; + +console.log(/hyphenated-string$/.test(strToSearch)); // test string w/ regular expression + +console.log(strToSearch.indexOf('hyphenated-string') === strToSearch.length - 'hyphenated-string'.length); // indexOf + +console.log(strToSearch.endsWith('hyphenated-string', 21)); // endsWith \ No newline at end of file diff --git a/es6/includes.js b/es6/includes.js new file mode 100755 index 0000000..c4a8f16 --- /dev/null +++ b/es6/includes.js @@ -0,0 +1,9 @@ +'use strict'; + +let strToSearch = 'a-really-long-hyphenated-string'; + +console.log(/long/.test(strToSearch)); // test string w/ regular expression + +console.log(strToSearch.indexOf('long') > -1); // indexOf + +console.log(strToSearch.includes('long')); // includes \ No newline at end of file diff --git a/es6/starts-with.js b/es6/starts-with.js new file mode 100755 index 0000000..2a8579c --- /dev/null +++ b/es6/starts-with.js @@ -0,0 +1,9 @@ +'use strict'; + +let strToSearch = 'a-really-long-hyphenated-string'; + +console.log(/^a-really/.test(strToSearch)); // test string w/ regular expression + +console.log(strToSearch.indexOf('a-really') === 0); // indexOf + +console.log(strToSearch.startsWith('lly', 5)); // startsWith \ No newline at end of file