Last active
February 2, 2018 21:02
-
-
Save caglarorhan/6cb3bd11597957716cbb30d65afca64b to your computer and use it in GitHub Desktop.
WarmerTemperature-DistanceOfDay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number[]} temperatures | |
| * @return {number[]} | |
| */ | |
| var dailyTemperatures = function(temperatures) { | |
| let outPut = []; | |
| //let test=[]; | |
| const howMany = temperatures.length; | |
| temperatures.forEach(function(i,index){ | |
| let count=1; | |
| let isIt=false; | |
| for(var xcv=index+1; xcv<=howMany-1;xcv++){ | |
| if(temperatures[index]<temperatures[xcv] && !isIt){ | |
| outPut.push(count); | |
| //test.push([temperatures[index],temperatures[xcv]]); | |
| isIt=true; | |
| break; | |
| } | |
| count++; | |
| } | |
| if(!isIt){ | |
| outPut.push(0); | |
| //test.push('Nothing bigger after me:'+temperatures[index]) | |
| } | |
| }); | |
| return outPut; | |
| //return test; | |
| }; |
Author
Author
bug solved, test array added for output testing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
little bug