Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if an array contains a number in JavaScript
#1
// Check if an array contains a number

const ratings = [1, 2, 3, 4, 5];

let result = ratings.includes(4);

document.write(result);
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Messages In This Thread
Check if an array contains a number in JavaScript - by Qomplainerz - 04-04-2023, 07:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  JavaScript - Array find() example (returns the value) Qomplainerz 0 541 04-04-2023, 08:12 AM
Last Post: Qomplainerz
  JavaScript Array findIndex() examples (returns the index) Qomplainerz 0 479 04-04-2023, 08:10 AM
Last Post: Qomplainerz
  JavaScript exercises and solutions - Identify if a number is odd or even Qomplainerz 0 374 04-04-2023, 07:56 AM
Last Post: Qomplainerz
  JavaScript exercises and solutions - Iterating through an array with keys and values Qomplainerz 0 417 04-04-2023, 07:52 AM
Last Post: Qomplainerz
  JavaScript - Get the length of an array Qomplainerz 0 414 04-04-2023, 07:45 AM
Last Post: Qomplainerz
  JavaScript array constructor Qomplainerz 0 417 04-04-2023, 07:43 AM
Last Post: Qomplainerz
  JavaScript Array copyWithin() example Qomplainerz 0 423 04-04-2023, 07:43 AM
Last Post: Qomplainerz
  JavaScript Array entries() example Qomplainerz 0 414 04-04-2023, 07:42 AM
Last Post: Qomplainerz
  JavaScript Array every() example Qomplainerz 0 408 04-04-2023, 07:42 AM
Last Post: Qomplainerz
  JavaScript Array fill() method examples Qomplainerz 0 426 04-04-2023, 07:41 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 5 Guest(s)