I want to write a factorial function in javascript. I have tried the following: It is not working. Answer You used while(n>=0) instead of while(n>=2). Using n>=0 will make the end of the while loop multiply n by 0. You should also use the === operator to prevent values that are not numeric. You also …
Tag: javascript
How to add mattooltip by custom directive in Angular
I am creating a custom directive called TooltipDirective whihc is going to add matTooltip to every host element, code is like below In my html I have two elements to compare the result in the result html tooltip and mattooltip attributes are added but it doesn’t show the tooltip. and rendered html is li…
SetCustomValidity not working
I am trying to create a custom error message when a number which is too high or low is entered in the “size” element. However, I am unable to make this work. I am a beginner so a solution which involves the least changes to my existing code would be most appreciated. Answer The problem with setCus…
How to get the same fingerprint that AWS uses from x.509 with node-forge?
How to get the certificate ID / fingerprint of an x.509 certificate using node-forge? Update I need this for AWS IoT. I’ve been investigating and ended up that AWS probably uses some fingerprint algorithm to extract the certificate ID. It is not baked into the cert, probably the public key is used as a …
JQuery : Disable multiple on multiple based on array of selected values
I do have a form with 3 (or more) <select> elements with the class ‘products-combo’ and same <option> values. Objective : Disable the particular <option> in every <select> if that <option> is selected in any of the <select> elements. And re enable the previous &…
How do I use firebase storage from a client side React app?
I’m trying to write a file into cloud storage from within my React app. I created a new React app using the create-react-app tool. I believe I have followed the correct instructions to get a storage reference, with code like this: this.storage = firebase.storage();. But, no matter how I configure fireba…
Array Left Rotation in Javascript will log to console but not return
I’m working on the array left rotation on Hackerrank. The solution that I have will console.log the array containing the correct result, but will not work using return. Here’s the detail from their site – “Print a single line of n space-separated integers denoting the final state of th…
Multi-slot transclusion in Angular 6
I am trying to create a component with multi-slot transclusion in Angular 6, following this blog post (which is for Angular 2). I created a component: and then I am trying to use it like this But it throws a compile error: ERROR in : ‘level-icon’ is not a known element What am I missing here? I re…
React js fetch API
I am learning React.js and trying to fetch API like this and this is the error I get http://prntscr.com/k36ggq I am pretty new in this, so if anyone can help me with this that would be great. Thanks Answer Try by setting the header as follows. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS You just re…
Photoswipe opens only first or second image
I need to have every two of images in gallery embed with extra <div>. I managed Photoswipe to use all images in that gallery. But I can’t fix problem: when I click on any thumb (not first or second one), Photoswipe every time opens only first or second image from firs <div>. Codepen DEMO her…