Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
36 changes: 36 additions & 0 deletions src/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,44 @@
<head>
<meta charset="UTF-8">
<title>Starting JS</title>

</head>
<body>

<h1> hello javascript</h1>

<p> you are so nice!</p>

</body>

<script type="text/javascript" src="http://underscorejs.org/underscore.js">
</script>

<script type="text/javascript">
var array = [2, 4, 6, 18, 10, -3];
var group = _.groupBy(array, function (num) {
return num % 2
});
console.log(group);
console.log(_.max(array));
</script>

<script type=" text/javascript">
var x =1;
for (var i = 1; i < 6; i++) {
x *= i;
}

console.log(x);

function factorielle(x) {
var x2 = 1;
for (var i = 1; i < x+1; i++) {
x2 *= i;
}
return x2;
}
console.log(factorielle(8));

</script>
</html>
3 changes: 3 additions & 0 deletions src/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var x = 2+2;
console.log(x);

16 changes: 16 additions & 0 deletions src/types/number.js
Original file line number Diff line number Diff line change
@@ -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);
38 changes: 38 additions & 0 deletions src/types/string.js
Original file line number Diff line number Diff line change
@@ -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.