QP School
Check if an array contains a string in JavaScript - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: JavaScript Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=6)
+--- Thread: Check if an array contains a string in JavaScript (/showthread.php?tid=4074)



Check if an array contains a string in JavaScript - Qomplainerz - 04-04-2023

// Check if an array contains a string

const colors = ['red', 'green', 'blue'];
const result = colors.includes('red');

document.write(result);