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 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..e6c14f3 --- /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("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