Open2

第4章少し高度なデータ

missedboymissedboy

Section_1 配列に複数の値をまとめる

c4_1_1.js
let walks=["抜き足", "差し足", "忍び足"];
console.log(walks[1]);
let walks1=["抜き足", "差し足", "忍び足"];
console.log(walks1);
walks[1]="駆け足";
console.log(walks);
c4_1_2.js
let ninja=["佐助", "才蔵", "六郎"];
let samurai=["信長", "秀吉", "家康"];
let people=[ninja, samurai];
console.log(people);
console.log(people[0][0]);
c4_1_3.js
let shogun=["家光", "家網"];
shogun.push("網吉");
console.log(shogun);
shogun.unshift("秀忠");
console.log(shogun);
let matsudaira=["家康", "健"];
shogun=shogun.concat(matsudaira);
console.log(shogun);
shogun.splice(5, 1);
console.log(shogun);
let shodai=shogun.pop();
console.log(shogun);
console.log(shodai);
shogun.unshift(shodai);
console.log(shogun);
missedboymissedboy

Section_02 配列を操作する

c4_2_1.js
let daysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
console.log(daysInMonth);
console.log(daysInMonth.includes(28));
console.log(daysInMonth.includes(29));
c4_2_2.js
let daysInMonth1=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
console.log(daysInMonth1.indexOf(30));
console.log(daysInMonth.lastIndexOf(30));
c4_2_3.js
let week1=["月", "火", "水", "木", "金"].fill("祝");
let week2=["月", "火", "水", "木", "金"].fill("祝", 2);
let week3=["月", "火", "水", "木", "金"].fill("祝", 2, 3);
console.log(week1);
console.log(week2);
console.log(week3);
c4_2_4.js
let music=["Aメロ", "サビ"];
console.log(music);
music.splice(1, 0, "Bメロ");
console.log(music);
c4_2_4.js
let music=["Aメロ", "サビ"];
console.log(music);
music.splice(1, 0, "Bメロ");
console.log(music);