Dexter Jin

Experiments07 Uploaded

function addPrice(amount) {
this.price = amount;
}
function book(title, author) {
this.title = title;
this.author = author;
this.addPrice = addPrice;
}
var bookList = new Array(new book("Perl1", "Mohtashim"),new book("Smith", "Mohtashim"),new book("Carl", "Mohtashim"),new book("Perl2", "Mohtashim"));
console.log(bookList);
console.log("After Sorting");
//bookList.sort(sortBook);
console.log(bookList);
function slice(str, start, end) {
}
var str = "Apples are round, and apples are juicy.";
var sliced = str.slice(1, 3);
console.log( sliced );
console.log( slice(str, 1, 3));
function reverse (input) {
}
var arr = [0, 1, 2, 3];
console.log ("Reversed array is : " + arr.reverse() );
console.log ("Reversed array is : " + reverse(arr));
var alpha = ["a", "b", "c"];
var numeric = [1, 2, 3];
var alphaNumeric = alpha.concat(numeric);
console.log("alphaNumeric : " + alphaNumeric );
var numbers = [1, 4, 9];
var element = numbers.pop();
console.log("element is : " + element );
var numbers = new Array(1, 4, 9);
var length = numbers.push(10);
console.log("new numbers is : " + numbers );
var arr = [0, 1, 2, 3].reverse();
console.log("Reversed array is : " + arr );
console.log("Reversed Again : " + arr.reverse());
var element = [105, 1, 2, 3].shift();
console.log ("Removed element is : " + element );
var arr = new Array("orange", "mango", "banana", "sugar");
var length = arr.unshift("water");
console.log("Returned array is : " + arr );
console.log("Length of the array is : " + length );
var test = new Array(1,2,3,4,5,6);
for (var aa in test) {
console.log(aa); // Set breakpoint here
}
function concatenate(first, last)
{
var full;
full = first + last;
return full;
}
function secondFunction()
{
var result;
result = concatenate('Zara', 'Ali');
console.log (result );
}
secondFunction();
var val = new Number(100.000);
console.log(val.toExponential());
console.log(val.toFixed());
console.log(val.toLocaleString());
console.log(val.toPrecision());
console.log(val.toString());
function addPrice(amount) {
this.price = amount;
}
function book(title, author) {
this.title = title;
this.author = author;
this.addPrice = addPrice;
}
var myBook = new book("Perl", "Mohtashim");
myBook.addPrice(100);
console.log("Book title is : " + myBook.title);
console.log("Book author is : " + myBook.author);
console.log("Book price is : " + myBook.price);
var val = new String("test");
console.log(val.charAt(1));
console.log(val.charCodeAt(1));
console.log(val.concat("aaa"));
console.log(val.indexOf("st"));
console.log(val.indexOf("t"));
console.log(val.lastIndexOf("t"));
console.log(val.replace("te","a"));
console.log(val.slice(2));
console.log(val.split("es"));
console.log(val.substr(2,2));