snipt

Ctrl+h for KB shortcuts

JavaScript

Vérifie si le navigateur est Internet Explorer

1
2
3
function isIE() {
	return (navigator.userAgent.indexOf('MSIE') != -1);
}
https://snipt.net/embed/2d1b7424355d8fb27e2f9c2556b83d06/
/raw/2d1b7424355d8fb27e2f9c2556b83d06/
2d1b7424355d8fb27e2f9c2556b83d06
js
JavaScript
3
2019-05-29T09:28:09
True
False
False
/api/public/snipt/4839/
verifie-si-le-navigateur-est-internet-explorer
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">isIE</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="p">(</span><span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;MSIE&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
ie, internetexplorer, javascript, js

JavaScript

if user is really gay

1
2
3
function isUserReallyGay(){
   return prompt( "Are you gay?" ).toLowerCase() == "yes" && prompt( "Really?" ).toLowerCase() == "yes";
}
https://snipt.net/embed/7b0dc0e14be9e573b74c0c6a4c62aadb/
/raw/7b0dc0e14be9e573b74c0c6a4c62aadb/
7b0dc0e14be9e573b74c0c6a4c62aadb
js
JavaScript
3
2019-06-16T10:56:34
True
False
False
/api/public/snipt/3421/
if-user-is-reallly-gay
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">isUserReallyGay</span><span class="p">(){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="nx">prompt</span><span class="p">(</span> <span class="s2">&quot;Are you gay?&quot;</span> <span class="p">).</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;yes&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">prompt</span><span class="p">(</span> <span class="s2">&quot;Really?&quot;</span> <span class="p">).</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;yes&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
js

JavaScript

if user is gay

1
2
3
function isUserGay(){
    return prompt( "Are you gay?" ).toLowerCase() == "yes";
}
https://snipt.net/embed/cf9592601b597061ece46e5a82a60118/
/raw/cf9592601b597061ece46e5a82a60118/
cf9592601b597061ece46e5a82a60118
js
JavaScript
3
2019-06-16T10:51:00
True
False
False
/api/public/snipt/3419/
if-user-is-gay
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">isUserGay</span><span class="p">(){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="nx">prompt</span><span class="p">(</span> <span class="s2">&quot;Are you gay?&quot;</span> <span class="p">).</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;yes&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
js

JavaScript

if value equals four billion

1
2
3
function equalsFourBillion( value ){
    return value == 4000000000;
}
https://snipt.net/embed/1dc5cddcf7cea2b1cb785eed086f0320/
/raw/1dc5cddcf7cea2b1cb785eed086f0320/
1dc5cddcf7cea2b1cb785eed086f0320
js
JavaScript
3
2019-03-01T15:59:40
True
False
False
/api/public/snipt/3416/
if-value-equals-four-billion
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">equalsFourBillion</span><span class="p">(</span> <span class="nx">value</span> <span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="nx">value</span> <span class="o">==</span> <span class="mi">4000000000</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
js

JavaScript

if value is true

1
2
3
4
5
6
7
function isTrue( value ){
    if( value == true ){
        return true;
    }else{
        return false;
    }   
}
https://snipt.net/embed/877899fd6603b8cdee20d7cab7d62f84/
/raw/877899fd6603b8cdee20d7cab7d62f84/
877899fd6603b8cdee20d7cab7d62f84
js
JavaScript
7
2019-02-20T12:07:48
True
False
False
/api/public/snipt/3415/
if-value-is-true
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">isTrue</span><span class="p">(</span> <span class="nx">value</span> <span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">if</span><span class="p">(</span> <span class="nx">value</span> <span class="o">==</span> <span class="kc">true</span> <span class="p">){</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span><span class="k">else</span><span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="kc">false</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
js

JavaScript

remove all spaces from a string

/* remove all spaces from a string */
var1.split(' ').join('');
https://snipt.net/embed/16d331a9b990fc4ce98db4e4b99051b4/
/raw/16d331a9b990fc4ce98db4e4b99051b4/
16d331a9b990fc4ce98db4e4b99051b4
js
JavaScript
2
2019-06-15T09:32:51
True
False
False
/api/public/snipt/3272/
remove-all-spaces-from-a-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cm">/* remove all spaces from a string */</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">var1</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
"remove all spaces", js, string