JavaScript
const options = {
method: 'POST',
headers: {
'content-type': 'application/json',
'X-RapidAPI-Key': '56cf0d9c39msh90ab47fd56c02e6p1d2792jsn0f4dfaa46b90',
'X-RapidAPI-Host': 'motivational-quotes1.p.rapidapi.com'
},
body: '{"key1":"value","key2":"value"}'
};
fetch('https://motivational-quotes1.p.rapidapi.com/motivation', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
var msg = "Hello, World!";
console.log(msg);
test = []
test.push({"num": 1, "int": 2});
test.push({"num": 2, "int": 3});
test.push({"num": 3, "int": 4});
test.push({"num": 4, "int": 5});
var obj = new Object()
obj.num = 5;
obj.int = 6;
test.push(obj);
test.forEach(function(item) {
console.log(item.num + ", "+ item.int);
});
console.log('== Get index 0, 1 value');
test.splice(0,2).forEach(function(item) {
console.log(item.num + ", " + item.int);
});
console.log("==only values except index 0, 1 remain in the val")
test.forEach(function(item) {
console.log(item.num + ", " + item.int);
});
console.log("= change the object which name is 4")
var test3 = test.find(function(item){
return item.num == "4";
});
test3.num = "change to 100";
test.forEach(function(item) {
console.log(item.num + ", " + item.int);
});
console.log("== remove object which name is changed")
var index = test.indexOf(test3)
test.splice(index, 1);
test.forEach(function(item) {
console.log(item.num + ", " + item.int);
});