From ced7a0e3e5068e566fae851fc03f2cbaebcd7ef0 Mon Sep 17 00:00:00 2001 From: ga8 Date: Mon, 24 Oct 2016 10:25:23 +0200 Subject: [PATCH 1/3] My first push. --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file From 25f0f803d080585479e5a18d4070e3282ca8ebb0 Mon Sep 17 00:00:00 2001 From: ga8 Date: Mon, 24 Oct 2016 14:51:56 +0200 Subject: [PATCH 2/3] My second push. --- src/start.html | 36 ++++++++++++++++++++++++++++++++++++ src/start.js | 3 +++ src/types/number.js | 16 ++++++++++++++++ src/types/string.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/start.js create mode 100644 src/types/number.js create mode 100644 src/types/string.js diff --git a/src/start.html b/src/start.html index f3e471e..f17d8d4 100644 --- a/src/start.html +++ b/src/start.html @@ -3,8 +3,44 @@ Starting JS + +

hello javascript

+ +

you are so nice!

+ + + + + + + \ No newline at end of file diff --git a/src/start.js b/src/start.js new file mode 100644 index 0000000..e85865d --- /dev/null +++ b/src/start.js @@ -0,0 +1,3 @@ +var x = 2+2; +console.log(x); + diff --git a/src/types/number.js b/src/types/number.js new file mode 100644 index 0000000..5dd4218 --- /dev/null +++ b/src/types/number.js @@ -0,0 +1,16 @@ +var x = 2 ; +console.log(typeof x +); + +x=x+0.2; +console.log("x: ",x, typeof x +); + +x=parseInt("4"); +console.log("x: ",x, typeof x); + +var y = parseFloat("2.345"); +console.log("y: ",y,typeof y); + +var z = parseFloat("ah ah ah"); +console.log("z: ",z , typeof z); diff --git a/src/types/string.js b/src/types/string.js new file mode 100644 index 0000000..de5063f --- /dev/null +++ b/src/types/string.js @@ -0,0 +1,38 @@ + +var string = "hello World"; + +string +=" !"; + +console.log("string : ", string); + +var index = string.indexOf("lo"); +console.log("index of lo : ",index); + +string.indexOf("jo"); +console.log("index of jo : ",index); + +function contains(haystack, needle){ +return (haystack.indexOf(needle)>=0); +} + +console.log("true ou pas true : ", contains("jack", "ack"), contains("bourde", "h"), contains("jim", "jim")); +console.log("jack is back".includes("ack")); + + +var hello = "hello world"; +var found = hello.search(/orl/); +var alsoFound = hello.search(/world/i); +console.log("found: ", found, "also: ", alsoFound); + +var x = /(.)*(world)/i.test("hello World"); +console.log("x : ",x); + +var strange = /(.)*(world)/i.test("hello World here"); +console.log("strange : ",strange); + +var moreStrict = /(.)*(world)$/i.test("hello World here"); +console.log("moreStrict : ",moreStrict); + + +console.log("abc".substr(1,2)); // returns "bc" retourne a partir du deuxièeme élément +console.log("abc".substring(1,2)); // returns "b" retourne le deuxième élément \ No newline at end of file From 5f845f75ae3faeb02615bd7b7d793f15310c8b73 Mon Sep 17 00:00:00 2001 From: ga8 Date: Mon, 24 Oct 2016 15:01:15 +0200 Subject: [PATCH 3/3] My second push. --- src/types/string.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/string.js b/src/types/string.js index de5063f..e6c14f3 100644 --- a/src/types/string.js +++ b/src/types/string.js @@ -34,5 +34,5 @@ var moreStrict = /(.)*(world)$/i.test("hello World here"); console.log("moreStrict : ",moreStrict); -console.log("abc".substr(1,2)); // returns "bc" retourne a partir du deuxièeme élément -console.log("abc".substring(1,2)); // returns "b" retourne le deuxième élément \ No newline at end of file +console.log("abcdef".substr(1,2)); // returns "bc" : return 2 elements (second parameter) the elements b and the one after b. +console.log("abcdef".substring(1,2)); // returns "b" : substring takes indices. You can remember because it's the only one with an 'i' in the name. \ No newline at end of file