{"ScriptPreparationCode":null,"TestCases":[{"Name":"for i","Code":"const array1 = [2, 4, 6, 8, 10];\r\nconst array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\r\n\r\nconst filteredArray2 = [];\r\nfor (let i = 0; i \u003C array2.length; i\u002B\u002B) {\r\n if (array1.includes(array2[i])) {\r\n filteredArray2.push(array2[i]);\r\n }\r\n}\r\n\r\nconst orderedArray2 = [];\r\nfor (let i = 0; i \u003C array1.length; i\u002B\u002B) {\r\n for (let j = 0; j \u003C filteredArray2.length; j\u002B\u002B) {\r\n if (array1[i] === filteredArray2[j]) {\r\n orderedArray2.push(filteredArray2[j]);\r\n break;\r\n }\r\n }\r\n}\r\n\r\nconsole.log(orderedArray2);","IsDeferred":false},{"Name":"filter and map","Code":"const array1 = [2, 4, 6, 8, 10];\r\nconst array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\r\n\r\nconst filteredArray2 = array2.filter(value =\u003E array1.includes(value));\r\n\r\nconst orderedArray2 = array1.map(value =\u003E filteredArray2.find(item =\u003E item === value));\r\n\r\nconsole.log(orderedArray2);","IsDeferred":false}]}