CoDEVIANT #9 (3/31/19)

solution(‘abc’, ‘bc’) // returns truesolution(‘abc’, ‘d’) // returns false
  • I took a look at the problem and began to meditate.
  • Then I lost focus and realized that I was more likely to succeed if I got some spiritual guidance.
  • I took some Peyote and wandered into the forest to meet my spirit animal to see if she could help me connect with some way to talk to computers.
  • Eventually, she sat me down, and told me to read the docs.
function solution(str, ending){   return str.slice(-ending.length) == ending ? true: false;}
function solution(str, ending){ 
return str.endsWith(ending);
multiplication_table(3,3)1 2 32 4 63 6 9→[[1,2,3],[2,4,6],[3,6,9]]
function multiplicationTable(row,col){let answer = [];let rowArray;for(let i = 1; i <= row ; i++ ){rowArray = [];for(let c = 1; c <= col ; c++){rowArray.push(c*i);}answer.push(rowArray);}return answer;}
  • So…we decide we’re going to have a variable called answer that will be an empty array.
  • Then we allow rowArray to be a bit of a blank slate variable that exists in the scope of our function.
  • Then we create a for loop to go from the start to the end of the number that row represents starting at 1 (and not zero like usual) — We say that we’ll keep going until i is less than or equal to the value that row represents.
  • We make rowArray equal an empty array;
  • We create another for loop to iterate over the path from 1 to whatever number the variable col represents
  • We say that we’ll keep going until c is less than or equal to the value that col represents.
  • If c is equal to 1 and if i is also equal to 1 then you want to push that value of c to rowArray, otherwise you will want to push into rowArray the result of c times i.
  • Within the scope of the first for-loop, the one with i you’ll want to push rowArray into answer this will happen a number of times 😉
  • When all is said and done we just return answer.
function multiplicationTable(row,col){out = []for (var i = 1; i <= row; i++) {temp = []// console.log(temp)for (var j = 1; j <= col; j++) {temp.push(i*j)} out.push(temp)} return out}




is a web developer, opera singer, actor, and lover of cats. (

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Brief Intro to JavaScript Class

Is it a good idea to decouple Drupal with client-side frameworks?

Learning Javascript

5 Commonly Asked NodeJS Interview Questions

The JavaScript Event Propagation: Explained

Build your own Realtime Database with and MongoDB

The optimistic UI with React

Hoisting, Block-level Scoping & Arrow Function.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Rosales

Adrian Rosales

is a web developer, opera singer, actor, and lover of cats. (

More from Medium

Git: The Basics Of Version Control Management

SOLID| The First 5 Principles of Object-Oriented Design

Inversion of Control (IoC) in programming

Councilor Hamman answers Neo while laughing:  Of course. That’s it. You hit it. That’s control, isn’t it?

You should always do server-side validation! Always!