\nLet's place a mark X in the cell:\nin .. code .. write element.innerHTML = \"X\" clicked!\nputs a mark X
\nslide13. Tic Tac Toe: sample7.html No overwriting! Only write in an empty cell\n\nWhat's the empty condition?\nelement.innerHTML == \"\"\nrecall == is equality
\nslide14. Homework 6 Question 1: modify sample7.html to make an interactive tic tac toe player\nUsing the random number generator described in the previous lecture, add a button \"Click!\" that inserts a O in an empty cell.\nvar o = Math.floor(Math.random()*9)+1;\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random\nNote A:\nuse onclick with a new function, e.g. insert_" }

408/508 Computational Techniques for Linguists

408/508 Computational Techniques for Linguists
1 / 1
408/508 Computational Techniques for Linguists - slide 1 of 19 408/508 Computational Techniques for Linguists - slide 2 of 19 408/508 Computational Techniques for Linguists - slide 3 of 19 408/508 Computational Techniques for Linguists - slide 4 of 19 408/508 Computational Techniques for Linguists - slide 5 of 19 408/508 Computational Techniques for Linguists - slide 6 of 19 408/508 Computational Techniques for Linguists - slide 7 of 19 408/508 Computational Techniques for Linguists - slide 8 of 19 408/508 Computational Techniques for Linguists - slide 9 of 19 408/508 Computational Techniques for Linguists - slide 10 of 19 408/508 Computational Techniques for Linguists - slide 11 of 19 408/508 Computational Techniques for Linguists - slide 12 of 19 408/508 Computational Techniques for Linguists - slide 13 of 19 408/508 Computational Techniques for Linguists - slide 14 of 19 408/508 Computational Techniques for Linguists - slide 15 of 19 408/508 Computational Techniques for Linguists - slide 16 of 19 408/508 Computational Techniques for Linguists - slide 17 of 19 408/508 Computational Techniques for Linguists - slide 18 of 19 408/508 Computational Techniques for Linguists - slide 19 of 19
408508 Computational Techniques for Linguists Lecture 14 Todays Topics More Javascript functionality: strings, operators, conditionals, loops a quirk with assignment () Tic-tac-toe example contd. (step by step) Files: sample3.html,

Related Topics

Download this presentation From Below

"408/508 Computational Techniques for Linguists" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
408/508 Computational Techniques for Linguists Lecture 14<br>
02
Today's Topics More Javascript functionality:
strings, operators, conditionals, loops
a quirk with assignment (=)
Tic-tac-toe example contd. (step by step)
Files: sample3.html, sample4.html, sample5.html, sample6.html and sample7.html
on course webpage
Homework 6: your job, make it playable!<br>
03
Javascript: Strings Use either double quotes or single quotes (no difference)
escape using backslash, e.g. \", \n, \\
Properties:
"string".length
Methods (like a function but object-based):
.indexOf(string) returns position (0…length), -1 if not found
.search(regex) returns position
.replace(regex,string) replaces with string, returns result
.slice(index,index) substring from position to position
.substr(index,length) substring
.toLowerCase() case conversion
.toUpperCase()
.trim() remove whitespace from both ends
.charAt(index) single character at position
.split(separator) returns array, single characters if separator=""<br>