JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var test="1#2#Did You Know?#Digital is rapid! A pair of BioCarbon Engineering drones can plant almost 100 ,000 trees a day.#8#Yes\n2#2#Did You Know?#Starting this summer of 2017, Ikea's smart light bulbs will answer voice commands given to Amazon Alexa, Google Assistant, or Apple Siri. The Internet of Things (IoT) is revolutionising everyday appliances!#5#Unknown\n3#2#Did You Know?#Cemex's (a cement company) collaboration platform allows employees to share opinions, knowledge, and best practices. The ideas from every corner of Cemex have led to new initiatives and business outcomes.#5#Unknown\n4#2#Did You Know?#Cemex's (a cement company) collaboration platform allows employees to share opinions, knowledge, and best practices. The ideas from every corner of Cemex have led to new initiatives and business outcomes.#5#Unknown\n5#3#Did You Know?#Cemex's (a cement company) collaboration platform allows employees to share opinions, knowledge, and best practices. The ideas from every corner of Cemex have led to new initiatives and business outcomes.#5#Unknown\n";

//console.log(test);
var result = [];
var allRows = test.split(/\r?\n|\r/);
var week = '2';
var contentid='5,4,3,2,1';
var splitContentId = contentid.split(/,/);
var counterLoop = splitContentId.length;
for (var singleRow = 0; singleRow < allRows.length; singleRow++) {
      var rowCells = allRows[singleRow].split('#');

for(var zeus = 0 ; zeus < counterLoop; zeus ++){

  	if( rowCells[0]==splitContentId[zeus] && rowCells[1]==week )
	{
		console.log(rowCells[0] );
	}
}
}