AdjacentElementsProduct | CodeFights Intro Algorithm JavaScript Solution and Breakdown
Support our Community:
-Donate:
-Patreon:
-Code, Tech and Caffeine Facebook Group:
-Discord:
– Looking for a a Bootcamp check out DevMountain’s program where housing is included with the tuition:
Tutoring, Mentoring and Course Walkthroughs available:
Thank you to my Patreon Supporters Below:
-Check out youtube.com/user/cardinalslinkyband
Support me and visit my store at:
Internship, Part-Time, & Full time work for college students and recent grads:
Fan funding goes towards buying the equipment necessary to deliver 4k videos, 4k webcam, and a high quality microphone better audio. Any support is very appreciated!
My channel is here for aspiring programmers to learn easier and help debug any issues from the many great free resources available on the web.
Check out my other videos going over HTML, CSS, Ruby, Ruby on Rails, Java, JavaScript, Python, PHP, SQL, Command Line, BootStrap, jQuery, and WordPress from CodeCademy, CodeCombat, FreeCodecamp and more!
-~-~~-~~~-~~-~-
Please watch: “How I Became a Developer | My Developer Journey of the Last 3 Years | Ask a Dev”
-~-~~-~~~-~~-~-
Nguồn: https://tintucgame.net
Xem thêm bài viết khác: https://tintucgame.net/giai-tri/
Xem thêm Bài Viết:
- Ad Copy for PPC Crash Course Video from the Trada PPC Library
- [Hướng dẫn] Chạy QUẢNG CÁO FACEBOOK TIN NHẮN (messenger ads) – Siêu dễ Siêu cơ bản
- Legal Hot Topics_Nov 2018-Federal Security Clearance Adjudication
- RESET EPSON L380 , L383, L385, L485 ADJUSTMENT PROGRAM FULL VERSION FREE DOWNLOAD
- #Traveller1 – 3e Urban life – 1.VOCABULARY – ADJECTIVES DESCRIBING PLACES – B. Use some of the adj..
it is not true
Can you please update your code like this?
function adjacentElementsProduct(inputArray: number[]): number {
let largestproduct = inputArray[0] * inputArray[inputArray.length-1];
for(let i=0; i < inputArray.length-1; i++)
{
const product = inputArray[i] * inputArray[i+1]
largestproduct = largestproduct < product ? product :largestproduct;
}
return largestproduct;
}
console.log(adjacentElementsProduct([3, 6, -2, -5 ,7, 3]));
I could not do with PHP, it error in test 8 …. can anyone help me?
That was really helpful, thanks
I don't know you but I'm glad I came across your videos
damn son
dude this is exactly what I have but it says time limit exceeded
How do you not get a rangeError at the last iteration of your loop? You are looking for an item at a spot that does not exist then: inputArray[i+1].
Does JS not mind if you do that?
this was a huge jump from the previous challenge "checkPalidrome", this is way beyond me -_-
ternary operator is also called a conditional statement
This is my solution 🙂
let arr = [0,1,2,3,4,5,4];
Array.prototype.prod = function(i) {
return this[i] * this[i+1];
}
function maxProd(arr) {
let productsArr = [];
for (let i = 0; i < arr.length – 1; i++) {
productsArr.push(arr.prod(i));
}
return Math.max(…productsArr);
}
console.log(maxProd(arr));
Oh! my solution was pretty similar to yours. I used a traditional if-statement rather than the es6 version.
first comment woot