I thought I can define a var in an if statement and use it later in the following code. Why is this not working in my example?   let a = prompt('1', '');   if (a == 1) {   let x = 10;   let y = 20;   let z = x + y; } else {   let z = 50; }  alert(z);    I'm pretty new to JS, thats why this error comes up for me. What would be the correct way to override z if the if is false?
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?
I use Stack Overflow a lot and have noticed a certain trend that I myself got caught up in at one time of using the phrase "I am having a problem" in place of "I have a problem."  I would use this phrase for an event in the future, for example, "I am having a steak dinner tonight," but for a problem that I need solved and am asking for a solution, I'd use "I have a problem..."   What would force us to use this phrase? Is it even valid English for the present tense? How can I say this? Can a shadow move faster than the speed of light? I'm just a layman with no real science background  (a) I'm not really sure what a shadow is. Some people are saying that it's the absence of something (a photon?) and therefore it is not subject to laws of physics. But I know when I'm in a shadow and when in sunlight... that's "information", and I thought that information flow can't break the speed of light limit.  (b) Some others use the laser pointer/flicking wrist example to talk about laser dots moving faster than light speed. But that can't be right, can it? The photons from the laser point have to travel from A to B and (after wrist flick) from A to C ... but the photons are all moving at the speed of light - there's no law-breaking in moving the laser dot from point B to point C because the photons are moving either from A to B or A to C ... the distance from B to C is not material (is it?).  (c) Also, can a shadow be thought of as a gap in a photon flow? E.g. if I interrupt a beam of single photons then can I think of it as e.g. PPPSSSPPPSSSPPPSSSPPP, etc where P = photons and S(shadow) = no photon &amp;, if so, the "SSS" is effectively travelling at the speed of light ... no faster. The integral $\int_0^\infty \dfrac{x \sin(x)}{x^2+1} dx$ How to calculate: $$\int_0^\infty \frac{x \sin(x)}{x^2+1} dx$$ I thought I should find the integral on the path  $[-R,R] \cup \{Re^{i \phi} : 0 \leq \phi \leq \pi\}$.  I can easily take the residue in $i$ $$  Res_{z=i} \frac{x \sin(x)}{x^2+1}  \quad = \quad \frac{i (e^{ii}-e^{-ii})}{2i}  \quad = \quad \frac{i(\frac1e-e)}{2i} \quad = \quad \frac1{2e}-\frac e2 $$ I know that the integral on $[-R,R]$ will get nearby the real value of $ \frac12\int_0^\infty \frac{x \sin(x)}{x^2+1} dx$. That means that I'm done if I show that the integral on the other part of the path will be small, here is an attempt to do so:  $$ \left|\frac{x \sin(x)}{x^2+1} \right|  \quad \leq \quad  R \cdot \frac{|\sin x|}{R^2-1} $$ I could rewrite $\sin x$ but it becomes nasty. Can you help me with this? Escape string for use in Javascript regex Zero to the zero power – is $0^0=1$? Python Script to Add Fields to Feature Classes I have to try to add a field called 'Name' to a bunch of different feature classes using python, and then access the name of the feature class to fill in the field. I have no idea how to even start this! I know I need a loop but that's all I know. I have a bunch of magnets (one of those game-board thingies) given to me when I was a school-going lad over 20 years ago, and the magnets feel just as strong as it was the day it was given.   As a corollary to this question , is there a way to determine how long a permanent magnet will remain a magnet?   Addendum: Would two magnets remain a magnet for a shorter duration if they were glued in close proximity with like poles facing each other? I have been attempting this problem for a while, it is an assignment problem so I don't want somebody to just post the answer, I'm just looking for hints.  Let $\mathfrak{u}(n,\mathbb{C})$ be the Lie algebra of strictly upper triangular $n\times n$ matrices over $\mathbb{C}$.  I am trying to show that $\mathfrak{u}(n,\mathbb{C})$ is a nilpotent Lie algebra for $n\geq 2$.  This is what I have looked at so far.  I have done some explicit calculations (I shall omit the bulk of them and just summarise below) for $n=2,3,4$ and have come up with some ideas.  Let $L=\mathfrak{u}(n, \mathbb{C})$.  If $n=2$,  $L^1 = [L, L] = &lt;0&gt;_{\mathbb{C}}$  So $L$ is nilpotent.  If $n=3$,  $L^1 = [L, L] = &lt;e_{13}&gt;_{\mathbb{C}}$  $L^2 = [L, L^1] = &lt;0&gt;_{\mathbb{C}} = \left\{ 0 \right\}$  So, $L$ is nilpotent.  If $n=3$  $L^1 = [L,L] = &lt;e_{13},e_{14},e_{24}&gt;_\mathbb{C}$  $L^2 = [L,L^1] = &lt;e_{14}&gt;_{\mathbb{C}}$  $L^3 = [L, L^2] = &lt;0&gt;_{\mathbb{C}} = \left\{ 0 \right\}$  So, $L$ is nilpotent.  So my hypothesis so far is that for an arbitrary $m\in\mathbb{N}$, $L^{m-1}=\{0\}$  My instinct is to do this by induction. My base case, $n=2$ has already been shown. Now I assume that $\mathfrak{u}(n,\mathbb{C})$ is nilpotent for $n=k$ ($k\in\mathbb{N}$) and consider the case for n=k+1.  However, I have no idea how to link these two cases together. I have read in Introduction to Lie Algebras and Representation Theory - J.E. Humphreys that $L^k$ should be spanned by basis vectors $e_{ij}$ where $j-i=k+1$ - however in my calculations for $L^1$, I obtain an $e_{14}$ which does not satisfy 4-1=2.  Am I missing something completely obvious? Or have I made a mistake somewhere? (I have checked my calculations numerous times, but cannot find any errors!)  Thanks,  Andy. This happens pretty much every time I try to bake normal maps. It's quite a broad error message and I still don't know exactly what the problems I'm having are, only that if I keep clicking things for half an hour eventually it sometimes just works.  My understanding of the things needed:   A "Generated" blender Image that the normals are written to (In UV/Image Editor, click Image->New)   Tell blender that this is the bake output, below (this is the really confusing bit which blender seems to try to guess and fails)  A UV Map for the low poly model (you only need the geometry of the high poly and it doesn't need a UV map) Under Bake, in the rendering tab:   Bake Mode = Normals Normal Space = Tangent Selected to Active = ✓ (for the next bit)  Select the high rez object first, then the low poly object With the two objects selected, click Bake (you may have to move the mouse to see the error pops up)   Now, from what I can tell the only  (with regard to the setup and apart from the internals of baking) is how blender finds the output image:   Cycles  Have a material using an ImageTexture node which points to your normal map output. Then  says the node must be selected, but  doesn't mention selecting. Blender Render  Have a texture attached to the material that uses the image.  is pretty vague on assigning the output image. Sometimes I've found hitting tab to go to edit mode and selecting the normal map image in the UV editor to help, or at least it seemed to.   I would like to know the exact details of what blender goes looking for when you hit Bake, rather than have to guess by following tutorials. For example, it seems to look for the high and low poly objects in your selection and based off the order you select them. How does it find the normal map/image to write to for both cycles and blender render? Does the Texture need to Influence Normals or does it just need to reference the Image? etc... Note that (1) all norms on finite dimensional vector space are equivalent.  And here (2) norms on vector space are equivalent iff they have same topology.   Question : How can we prove (2) ? Please recommend reference  Thank you in anticipation I want to digitize my old family albums using a scanner and there are lots of photos in them. Thus far, my method has been to scan 4 images at a time and then manually cropping them in a simple editor like Picasa or Windows Live Photo Gallery. This has been pretty time consuming as each scan is followed by 4 crop operations. Scanning each image individually would possibly be even more time consuming.  Is there any software or simple plugin (preferably free) that does this job? The best solution I have found is in , but that's an overkill. Is there a similar feature for one of the free photo editors like Paint.NET or GIMP? Opposite of "straight talk" What's the best option to display Unicode text (hebrew, etc.) in VB6 I have some customers who want to use our speech therapy software in Hebrew.  The programs are in VB6. The best option I'm aware of are:   use the Forms 2.0 controls from MS Office, but you can't distribute them.    $899   $499   Any other options? Can I publish parts of the Ph.D thesis as a paper in a journal? Summarizing flatness of county with statistic Elevation variance per square mile I need to classify every county in the US as either hilly, moderately hilly, or flat. Accuracy is not critical, just a rough classification. I used R and followed the advice in  answer to import elevation and counties and calculated the zonal variance. This was inherently biased towards larger counties since they have more surface for hills, so I need to divide by area. If I divide variance by square miles does that reasonably represent hilliness? The preliminary results seem decent, with the highest values being places like Colorado, Hawaii, Montana, etc. The client can do several actions per frame, for instance, requesting a movement, shooting etc. Should i send a packet to the server for each action the client performed during the frame, or should i stack them in an unique packet and send it at the end of the frame?  EDIT: i'm using Jmonkeyengine and the provided network API SpiderMonkey. How do I change the plymouth bootscreen? With regards to Plymouth --  Are there alternative boot screens available?  What's the easiest way to change the boot screen? An easy bash completion tutorial? Is there a way to make PythonTEX compile as of today in Overleaf V2 ?  \documentclass[]{article} \usepackage[utf8]{inputenc} \usepackage{pythontex}  \begin{document} \begin{pyverbatim} def calc_ellipticity(theta, delta):     theta = np.deg2rad(theta)     psi = np.arcsin(np.sin(2*theta) * np.sin(delta))/2     return np.tan(psi) \end{pyverbatim} \end{document}   Compiling gives : ? PythonTEX ?