Skip to content

Instantly share code, notes, and snippets.

function findBoomrangs(arr){
let count = 0;
for(let i=0; i<arr.length-2;i++){
if(arr[i] == arr[i+2]){
count = count +1;
}
}
//3,,,,,,,,,,,,,,,,,,,
let farm3 = [['W', 'C', 'W'], ['C', 'W', 'C'], ['C', 'C', 'C'], ['C', 'C', 'W'], ['C', 'C', 'C']]
// has 4 water outlets
function waterOutlets(farm){
let count = 0;
for(let i = 0; i < farm.length;i++){
for(let j=0; j< farm[0].length;j++){
if(farm[i][j] == 'W' ){
// // Write a function which takes in the farm and returns total spots in the farm. For eg.
// let farm = [['W', 'C', 'C'], ['C', 'C', 'C'], ['W', 'W', 'C'], ['C', 'C', 'W']];
// // // has 4 rows and each row has 3 spots so total number of spots would be 12.
// console.log(totalSpots(farm)); // should print 12
// function totalSpots(farm){
// return farm.length * farm[0].length;
// }
/*
hammer('magic' , maxwell(-2, -3), 'butter');
maxwell(-2,-3)
rossy(-2);
return false;
return true;
hammer("magic",true,'butter')
rossy("magic")
return false;
return "magic" + "butter" -> magicbutter
// // Implement the function fizz which prints all the numbers from 1 to 100 but for every third number it prints `fizz` instead.
// /* For eg. it should print:
function fizz(){
for(let i=1; i<=100 ;i++ )
{
if (i%3 == 0){
// pairElements([1, 2, 3, 4, 5, 6, 7]) ➞ [[1, 7], [2, 6], [3, 5], [4, 4]]
// pairElements([1, 2, 3, 4, 5, 6]) ➞ [[1, 6], [2, 5], [3, 4]]
// pairElements([5, 9, 8, 1, 2]) ➞ [[5, 2], [9, 1], [8, 8]]
// pairElements([]) ➞ []
var newArray = new Array();
function pairElements(arr){
if(arr.length%2 == 0){
// canShop([
// { product: "Milk", quantity: 1, price: 1.50 },
// { product: "Cereals", quantity: 1, price: 2.50 }
// ], 5) ➞ true // because we have sufficient amount to purchase all the grocery items.
// canShop([
// { product: "Milk", quantity: 1, price: 1.50 },
// { product: "Eggs", quantity: 12, price: 0.10 },
// { product: "Bread", quantity: 2, price: 1.60 },
// { product: "Cheese", quantity: 1, price: 4.50 }
// isUniqueRepeated('aaaaa');
// ➞ true // because the character `a` is the single character which is repeated over the length of the array.
// isUniqueRepeated('aaabba');
// ➞ false // because there is not a single character which is repeated over the length of the array.
// isUniqueRepeated('');
// ➞ true // for empty strings return true.
// isUniqueRepeated('abcdef');