Skip to content

Commit 10ace97

Browse files
committed
added chapter example code for chapter 4, also added package.json for readline-sync
1 parent 53ae9ff commit 10ace97

9 files changed

+50
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Bruce's beard');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const input = require('readline-sync');
2+
3+
let num1 = input.question("Enter a number: ");
4+
let num2 = input.question("Enter another number: ");
5+
6+
console.log(num1 + num2);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
console.log(42000);
2+
console.log(42,000);
3+
4+
console.log(42, 17, 56, 34, 11, 4.35, 32);
5+
console.log(3.4, "hello", 45);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
console.log(typeof "17");
2+
console.log(typeof "3.2");
3+
4+
console.log(typeof 'This is a string');
5+
console.log(typeof "And so is this");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Dependencies for Chapter 4: Data and Variables",
3+
"version": "1.0.0",
4+
"description": "This package.json file includes all dependencies needed to run code within files contained in this directory",
5+
"main": "index.js",
6+
"dependencies": {
7+
"readline-sync": "^1.4.10"
8+
},
9+
"scripts": {
10+
"start": "node index.js"
11+
},
12+
"author": "John Woolbright",
13+
"license": "ISC"
14+
}
15+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const input = require('readline-sync');
2+
3+
let name = input.question("Enter your name: ");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const input = require('readline-sync');
2+
3+
let info = input.question("Question text... ");
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
console.log(Number("2345"));
2+
console.log(typeof Number("2345"));
3+
console.log(Number(17));
4+
5+
console.log(Number("23bottles"));
6+
7+
console.log(String(17));
8+
console.log(String(123.45));
9+
console.log(typeof String(123.45));
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.log(typeof "Hello, World!");
2+
console.log(typeof 17);
3+
console.log(typeof 3.14);

0 commit comments

Comments
 (0)