Skip to content

Commit b28497a

Browse files
Continued learning js, installed node
1 parent bbf6e04 commit b28497a

File tree

413 files changed

+139398
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+139398
-4
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<h1>Exercises</h1>
99

1010
</body>
11-
</html>
11+
</html>

js/exercises.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ window.onload = main;
44
function main(){
55
//Calling the end function
66
console.log("Testing end function: " + end("Bastian", "n"));
7-
7+
console.log("Testing repeat function: " + repeat("abc", 3));
8+
console.log(truncate("A-tisket a-tasket A green and yellow basket", 11));
89
}
910

1011
/**
11-
FreeCodeCamp Bonfire: Confirm The Ending
12+
Confirm The Ending
1213
A function that will look if a string ends with the following target.
1314
1415
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
@@ -27,4 +28,52 @@ function end(str, target) {
2728
return true;
2829
}
2930
return false;
30-
}
31+
}
32+
33+
/**
34+
Repeat a string repeat a string
35+
A function which will repeat a string x times and return it.
36+
37+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
38+
@parameters
39+
str - Main string that will be repeated
40+
num - The number of times it should be repeated
41+
42+
@returns string
43+
*/
44+
function repeat(str, num) {
45+
// repeat after me
46+
47+
//Creating a new variable to hold the original value so we can use it to append our str variable
48+
//each loop.
49+
var originalStr = str;
50+
51+
//Setting the str variable to an empty string incase a negative number would be added in the parameters
52+
str = "";
53+
54+
//Looping through x ammount of times depending on the num entered in the functions parameters
55+
for(var x = 0; x < num; x++){
56+
//appending the str that we will return with the original string entered into the function
57+
str += originalStr;
58+
}
59+
60+
//return the repeated value
61+
return str;
62+
}
63+
64+
function truncate(str, num) {
65+
// Clear out that junk in your trunk
66+
if(str.length > num){
67+
str = str.slice(0, num);
68+
if(num <= 3){
69+
str += "...";
70+
}else{
71+
str = str.slice(0, str.length - 3);
72+
str += "...";
73+
}
74+
}
75+
76+
return str; //Comment
77+
}
78+
79+

js/hellonode.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var http = require('http');
2+
var irc = require('irc'); //https://www.npmjs.com/package/irc
3+
4+
var client = new irc.Client('irc.freenode.net', 'BrokenBot', {
5+
channels: ['#gobotter'],
6+
});
7+
8+
client.addListener('error', function(message) {
9+
console.log('error: ', message);
10+
});
11+
12+
var server = http.createServer(function(req, res) {
13+
res.writeHead(200);
14+
res.end('Hello Http');
15+
});
16+
server.listen(8080);

node_modules/irc/.jscsrc

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/irc/.npmignore

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/irc/.travis.yml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/irc/CHANGES.md

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/irc/CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)