JSFiddle - React, Tailwind, and code Playground

JavaScript

var contents = [
	{name: 'a', type: 1},
	{name: 'b', type: 5},
	{name: 'c', type: 2},
	{name: 'd', type: 1}
];

contents.map((content, index, array) => {
    switch(content.type) {
        case 1:
            console.log("type is one and next type is: ", array[index+1] ? array[index+1].type : 'empty');
            break;
        case 2:
            console.log("type is two")
            break;
    }
});