JavaScript check if a string matches any element in an Array

In the following code we will be checking a string and check if any of the words in the string match some or any elements in an array.

We can imagine that our “stringToCheck” variable is an email or message response. We want to know if it contains a mention to afternoon, tomorrow, or evening. Presumably so we can automate something. Note that the matches are case sensitive.

// Check if any text in a string matches an element in an array

const stringToCheck = "Let's grab lunch tomorrow";
const arrayToCompareTo =["afternoon", "tomorrow", "evening"];

// We are checking to see if our string "stringToCheck" 
// Has any of the words in "arrayToCompareTo".
// If it does, then the result is true.  Otherwise false.
const resultsOfCompare = arrayToCompareTo.some(checkVariable => stringToCheck.includes(checkVariable));

if (resultsOfCompare == true){
    console.log(stringToCheck + " Contains a value in our Array " + arrayToCompareTo);
} else {
    console.log(stringToCheck + " Does NOT contain a value in our Array " + arrayToCompareTo);

More examples and ways to do it are available at the following link.

Bash array example

array=(one two three)
echo "Printing first object in array."  #Replace 0 with the place number of the array item
echo ${array[0]}

echo ""

echo "Whole array"
echo ${array[*]} 

echo "" 

echo "Array indexes" 
echo ${!array[*]}


Printing first object in array. 

Whole array
one two three

Array indexes
0 1 2

Clonezilla – Clone Windows 10 from single SSD to New Raid 0 SSD Volume

Boot up and create your raid array

Boot into Clonezilla and get to command line :cry: unfortunately you can’t clone from disk to raid in clonezilla interface, however we can do it from the command Line!

Basic steps are as follows. Replace raidarray with the name of your raid array.

  • Initialize raid array with dmraid -ay or kpartx -a /dev/mapper/raidarray
  • use gdisk to backup structure of source drive
  • Write gdisk backup to raid array
  • use ntfsclone to clone to raid array
  • ntfsclon –overwrite /dev/mapper/raidarray /dev/sdSOURCEDRIVE