Here's the code to display the elements of a matrix 'a' with elements from 1 to 100 that are divisible by 7 using a for loop and if statement in javascript:
index.tsx531 chars13 lines
In this code, we first create a 10x10 matrix 'a' with all elements initialized to 0. We then use a nested for loop to iterate through each row and column of the matrix. We calculate the value of each matrix element using the formula i * 10 + j + 1 (since javascript is 0-indexed). We then use an if statement to check if the value is divisible by 7 using the modulus operator %. If the value is divisible by 7, we assign it to the corresponding matrix element. Finally, we display the matrix by logging it to the console.
gistlibby LogSnag