<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Javascript Check If A Value Is In An Array Examples	</title>
	<atom:link href="https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/feed/" rel="self" type="application/rss+xml" />
	<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/</link>
	<description>Web Design and Web Development</description>
	<lastBuildDate>Thu, 26 Jun 2014 10:54:11 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>
	<item>
		<title>
		By: vins		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-114</link>

		<dc:creator><![CDATA[vins]]></dc:creator>
		<pubDate>Thu, 26 Jun 2014 10:54:11 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-114</guid>

					<description><![CDATA[i have some value for array and i give the value propmt for A. when i give User input A out will display -&gt;apple-2,grape-6 pls help me 

&lt;script type=&quot;text/javascript&quot;&gt;
var select = prompt(&quot;select u r fav jouice&quot;);
var myArray=[&quot;lemon&quot;,&quot;apple&quot;,&quot;orange&quot;,&quot;apple&quot;,&quot;lemon&quot;,&quot;grab&quot;,&quot;grab&quot;,&quot;lemon&quot;,&quot;apple&quot;,&quot;lemon&quot;,&quot;orange&quot;];
var result=new Array();
	for(var i=0; i&lt;myArray.length; i++)
	{
	var key=myArray[i].toString();
	if(!result[key]){
		result[key]=1;
	}else{
		result[key]=result[key]+1;
	}
	}
	for(var i in result){
		if(select==i)
		document.write(i + &quot; --&gt; count :&quot; + result[i])
		document.write(&quot;&lt;/br&gt;&quot;);
	}]]></description>
			<content:encoded><![CDATA[<p>i have some value for array and i give the value propmt for A. when i give User input A out will display ->apple-2,grape-6 pls help me </p>
<p><script type="text/javascript">
var select = prompt("select u r fav jouice");
var myArray=["lemon","apple","orange","apple","lemon","grab","grab","lemon","apple","lemon","orange"];
var result=new Array();
	for(var i=0; i<myArray.length; i++)
	{
	var key=myArray[i].toString();
	if(!result[key]){
		result[key]=1;
	}else{
		result[key]=result[key]+1;
	}
	}
	for(var i in result){
		if(select==i)
		document.write(i + " --> count :" + result[i])
		document.write("");
	}</script></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Olajide Temitope		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-113</link>

		<dc:creator><![CDATA[Olajide Temitope]]></dc:creator>
		<pubDate>Sat, 11 May 2013 14:27:40 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-113</guid>

					<description><![CDATA[Thanx alot, u rilly ar a life saver, av been on dis 4 wiks. God bless.]]></description>
			<content:encoded><![CDATA[<p>Thanx alot, u rilly ar a life saver, av been on dis 4 wiks. God bless.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rocky Dev		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-112</link>

		<dc:creator><![CDATA[Rocky Dev]]></dc:creator>
		<pubDate>Thu, 14 Mar 2013 19:53:20 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-112</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-111&quot;&gt;zaisharul&lt;/a&gt;.

Hi,
This is possible. I have updated the original article with Example 2. Simply review Example 2, follow the instructions and let me know if that solves your issue.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-111">zaisharul</a>.</p>
<p>Hi,<br />
This is possible. I have updated the original article with Example 2. Simply review Example 2, follow the instructions and let me know if that solves your issue.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: zaisharul		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-111</link>

		<dc:creator><![CDATA[zaisharul]]></dc:creator>
		<pubDate>Thu, 14 Mar 2013 12:57:48 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-111</guid>

					<description><![CDATA[Hi, nice explanation. But how would you match part of the string e.g. I wanted to find if my array element contains &#039;two&#039; .

var arr= [&quot;test one&quot;, &quot;test two&quot;, &quot;test three&quot;];

if (arr.indexOf(‘two’) != -1)
{
alert(‘Value exists in array.’);
}]]></description>
			<content:encoded><![CDATA[<p>Hi, nice explanation. But how would you match part of the string e.g. I wanted to find if my array element contains &#8216;two&#8217; .</p>
<p>var arr= [&#8220;test one&#8221;, &#8220;test two&#8221;, &#8220;test three&#8221;];</p>
<p>if (arr.indexOf(‘two’) != -1)<br />
{<br />
alert(‘Value exists in array.’);<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Robert		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-110</link>

		<dc:creator><![CDATA[Robert]]></dc:creator>
		<pubDate>Wed, 26 Sep 2012 19:47:46 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-110</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-109&quot;&gt;TAHIR&lt;/a&gt;.

Hi Tahir,
I did find some mistakes with your code. You have corrected the first issue and that was of the double &quot;i&quot;. Next, you are declaring array as var arr, but you are using an incorrect array name (temp). You don&#039;t have a temp array with values in it. You have an &quot;arr&quot; array. Other than that it should work. I fixed the entire code. You can find it below:
&lt;code&gt;	var srch = &#039;val four&#039;;
	var arr = [&#039;val one&#039;, &#039;val two&#039;, &#039;val three&#039;, &#039;val four&#039;, &#039;val five&#039;];	
	
	for(var i = 0; i&lt;= arr.length; i++)
	{
  		if(srch  == arr[i])
  		{
    		alert(&#039;this value is in array&#039;);
  		}
		else 
		{
			alert(&#039;this value is not in array&#039;);
		}	
	}&lt;/code&gt;
My code above it works for me. So try out the above code &amp; let me know how it goes.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-109">TAHIR</a>.</p>
<p>Hi Tahir,<br />
I did find some mistakes with your code. You have corrected the first issue and that was of the double &#8220;i&#8221;. Next, you are declaring array as var arr, but you are using an incorrect array name (temp). You don&#8217;t have a temp array with values in it. You have an &#8220;arr&#8221; array. Other than that it should work. I fixed the entire code. You can find it below:<br />
<code>	var srch = 'val four';<br />
	var arr = ['val one', 'val two', 'val three', 'val four', 'val five'];	</p>
<p>	for(var i = 0; i<= arr.length; i++)
	{
  		if(srch  == arr[i])
  		{
    		alert('this value is in array');
  		}
		else 
		{
			alert('this value is not in array');
		}	
	}</code><br />
My code above it works for me. So try out the above code &#038; let me know how it goes.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: TAHIR		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-109</link>

		<dc:creator><![CDATA[TAHIR]]></dc:creator>
		<pubDate>Wed, 26 Sep 2012 19:23:06 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-109</guid>

					<description><![CDATA[sorry for mistake instead of this code
&lt;code&gt;
if(srch == temp[ii])
&lt;/code&gt;

this is 
&lt;code&gt;
if(srch == temp[i])
&lt;/code&gt;

now please help]]></description>
			<content:encoded><![CDATA[<p>sorry for mistake instead of this code<br />
<code><br />
if(srch == temp[ii])<br />
</code></p>
<p>this is<br />
<code><br />
if(srch == temp[i])<br />
</code></p>
<p>now please help</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: TAHIR		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-108</link>

		<dc:creator><![CDATA[TAHIR]]></dc:creator>
		<pubDate>Wed, 26 Sep 2012 19:19:00 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-108</guid>

					<description><![CDATA[First of all thank you very much robert for your help
it really helped I was finding for this solution for 2 hours but finally I got it I faced 3 or 4 problems in doing this if you can help me a bit more if I write this code like this then why this is not working fine

&lt;code&gt;
var srch = &#039;val four&#039;;
var arr = [&#039;val one&#039;, &#039;val two&#039;, &#039;val three&#039;, &#039;val four&#039;, &#039;val five&#039;];
for(var i = 0; i &#060;= arr.length; i++)
{
   if(srch  == temp[ii])
  {
     alert(&#039;this value is in array&#039;);
  }
else {
   alert(&#039;this value is not in array&#039;);
}

&lt;/code&gt;
please tell me that why this is not working..
thanks again]]></description>
			<content:encoded><![CDATA[<p>First of all thank you very much robert for your help<br />
it really helped I was finding for this solution for 2 hours but finally I got it I faced 3 or 4 problems in doing this if you can help me a bit more if I write this code like this then why this is not working fine</p>
<p><code><br />
var srch = 'val four';<br />
var arr = ['val one', 'val two', 'val three', 'val four', 'val five'];<br />
for(var i = 0; i &lt;= arr.length; i++)<br />
{<br />
   if(srch  == temp[ii])<br />
  {<br />
     alert(&#039;this value is in array&#039;);<br />
  }<br />
else {<br />
   alert(&#039;this value is not in array&#039;);<br />
}</p>
<p></code><br />
please tell me that why this is not working..<br />
thanks again</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Prakash		</title>
		<link>https://theextremewebdesigns.com/blog/javascript-check-if-a-value-is-in-an-array/#comment-107</link>

		<dc:creator><![CDATA[Prakash]]></dc:creator>
		<pubDate>Wed, 25 Jul 2012 04:02:40 +0000</pubDate>
		<guid isPermaLink="false">https://theextremewebdesigns.com/blog/?p=344#comment-107</guid>

					<description><![CDATA[For the value &quot;find_this_value&quot; in your code, if my array contains duplicate values, and I want to find the index values of all these values how should I proceed.]]></description>
			<content:encoded><![CDATA[<p>For the value &#8220;find_this_value&#8221; in your code, if my array contains duplicate values, and I want to find the index values of all these values how should I proceed.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
