/    Sign up×
Community /Pin to ProfileBookmark

Create A Program to find the first specific letter indicated and alert.

Hi guys, I am trying to figure out how to have the function alert. It may be has something to do with my code. Please do help me.

Currently trying to find the first t among the paragraph word and alert it.

[url]http://jsbin.com/safahepome/edit?html,output[/url]

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Ay__351_eJun 02.2016 — 
<!DOCTYPE html>
<html>
<body>

<p id="demo">Among these words, create a program to find the first specific letTer indicated and have the progress stop afterwards. </p>


<script type="text/javascript">
var A =["t","T"];
var s = "";
var el=document.getElementById("demo");
// alert(typeof el.innerHTML); // string

for(var i=0; i<A.length; i++){
if(el.innerHTML.indexOf(A[i]) != -1){ s = el.innerHTML.indexOf(A[i]); break;}
}
alert("ilk t veya T harfi paragraftaki "+s+". karakter");

// bulunanı renklendirelim
var c=el.innerHTML.charAt(s);
el.innerHTML = el.innerHTML.replace(c,"<span style="color:red" >"+c+"</span>");
</script>

</body>
</html>

http://www.w3schools.com/js/js_datatypes.asp

http://www.w3schools.com/jsref/jsref_obj_string.asp
Copy linkTweet thisAlerts:
@Ay__351_eJun 02.2016 — 
<html>
<head>
</head>
<body>

<p id="demo">Among these words, create a program to find the first specific letTer indicated and have the progress stop afterwards. </p>



<script type="text/javascript">

var el = document.getElementById("demo");
// alert(el.innerHTML);

function Ara(metin, harf){
this.metin=metin;
this.harf=harf;
this.netice=-1
for(var i = 0; i < this.metin.length; i++){
// alert(this.metin.slice(i,this.harf.length + i ) );
if(this.metin.slice(i,this.harf.length + i ) == this.harf ){ this.netice= i; break; }
}

}



var tara= new Ara(el.innerHTML,"t");

alert(tara.netice);// 6

var Tara= new Ara(el.innerHTML,"T");

alert(Tara.netice);// 66

</script>
</body>
</html>
Copy linkTweet thisAlerts:
@jamesleehorngyiauthorJun 02.2016 — Thanks Ayse! That really helped! Appreciate your time
Copy linkTweet thisAlerts:
@jamesleehorngyiauthorJun 02.2016 — I have one question though. May i know what is the exclamation mark [COLOR="#FF0000"]![/COLOR] for? if(el.innerHTML.indexOf(A[i]) != -1)





Ben ünlem işareti için ne olduğunu biliyor miyim? (Google Translate)
Copy linkTweet thisAlerts:
@wbportJun 02.2016 — I have one question though. May i know what is the exclamation mark [COLOR="#FF0000"]![/COLOR] for? if(el.innerHTML.indexOf(A[i]) != -1)[/QUOTE]



Not equal.
Copy linkTweet thisAlerts:
@Ay__351_eJun 06.2016 — http://www.w3schools.com/js/js_comparisons.asp

!= not equal

! not

for(var i=0; i<A.length; i++){
alert(el.innerHTML.indexOf(A[i]));//6
alert(typeof el.innerHTML.indexOf(A[i]));// number
alert(typeof -1); // number
// 6 eşit değil -1 e
// 6 ≠ -1
// 6 != -1
alert(6 != -1);// true
if(el.innerHTML.indexOf(A[i]) != -1){ s = el.innerHTML.indexOf(A[i]); break;}
}


Number.prototype.notEqual=function(n){
// alert(this);
if(this == n ) {return false; }
return true;
}
var a = 6;
var b = -1;
alert(a.notEqual(b)); // true



<script type="text/javascript">
/*
Ve eşit değildir körle gören ve inanıp iyi işlerde bulunanla kötülükler eden; ne de az düşünmede, ne de az ibret almadasınız. mümin suresi 58.ayet

*/

alert("kör" != "gören");// true
alert("inanıp iyi işlerde bulunan" != "kötülükler eden"); // true

/*
"De ki: Temizle pis eşit olmaz...' (Mâide, 5/100), "De ki, gören ile görmeyen eşit olur mu? Ya da karanlıklarla aydınlık eşit olur mu?" ..." (Ra'd, 13/16), "Ölüler ile diriler eşit olmaz..." (Fâtır, 35/22), "De ki: Bilenlerle bilmeyenler eşit olur mu?..." (Zümer, 39/9).
*/

alert("temiz" != "pis"); // true
alert("gören" == "görmeyen");// false
alert("karanlıklar" == "aydınlık");// false
alert("ölüler" != "diriler");// true
alert("bilenler" == "bilmeyenler");//false

</script>




<script type="text/javascript">
// !(true or false)
// not(true or false)

function not(bu){
if(bu == true){return false;}
if(bu == false){return true;}
}


var temiz = true;
alert( not(temiz) ); // false
alert (!(temiz)) ; // false

</script>

Copy linkTweet thisAlerts:
@Ay__351_eJun 06.2016 — I tried this
<br/>
&lt;script type="text/javascript"&gt;
function not(bu){
// alert("bu = "+bu);
if(bu == true){return false;} <br/>
if(bu == false){return true;}

}

var t = "temiz";
alert(!(t)); // false
alert(not(t)); // undefined
&lt;/script&gt;

alert(!(t)); // false

alert(not(t)); // undefined

I change the code
<br/>
&lt;script type="text/javascript"&gt;
function not(bu){

// if(bu == true){return false;} // bu sat&amp;#305;ra gerek yokmu&amp;#351;
if(bu == false){return true;}
return false
}

var t = "temiz";
alert(!(t)); // false
alert(not(t)); // false
&lt;/script&gt;

alert(!(t)); // false

alert(not(t)); // false

I asked a question. I learned new code. I tried this code


&lt;script type="text/javascript"&gt;
function not(bu){
return bu === false;
}

var t = "temiz";
alert(!(t)); // false
alert(not(t)); // false

alert(!(true)); // false
alert(not(false)); // true
alert(!!(true)); // true
alert(not(not(false))); // false
alert(!(3&gt;20)); // true
alert(!!(3&gt;20)); // false
alert(not(3&gt;20)); // true
alert(not(not(3&gt;20))); // false
&lt;/script&gt;
Copy linkTweet thisAlerts:
@jamesleehorngyiauthorJun 07.2016 — Thanks Ayse, that's some various codes you have there! Appreciate your help!
×

Success!

Help @jamesleehorngyi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...